二维数组 第一次在网站中使用。。。。(代码 有待优化)
2013-08-20 13:58
330 查看
action
List<Company> qylist = companyService.getAll();
List<Pingyi> pylist;
cp = new String[qylist.size()][5];
for(int j = 0;j<qylist.size();j++){
cp[j][0] = qylist.get(j).getId()+"";
cp[j][1] = "0";
cp[j][2] = "0";
cp[j][3] = "0";
cp[j][4] = "0";
pylist = pingyiService.findByProperty("company_id",qylist.get(j).getId()+"");
for (int i = 0; i < pylist.size(); i++) {
if (pylist.get(i).getManyidu().equals("非常满意")) {
cp[j][1] = (Integer.parseInt(String.valueOf(cp[j][1]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("满意")){
cp[j][2] = (Integer.parseInt(String.valueOf(cp[j][2]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("一般")){
cp[j][3] = (Integer.parseInt(String.valueOf(cp[j][3]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("不满意")){
cp[j][4] = (Integer.parseInt(String.valueOf(cp[j][4]))+1)+"";
}
}
System.out.println("企业编号:"+cp[j][0]+"满意度调查:");
System.out.println(""+cp[j][1]+"|"+cp[j][2]+"|"+cp[j][3]+"|"+cp[j][4]+"|");
} -----------------------------------------------------------------------------------------------------------------------------------------------------------------
页面
<c:forEach items="${clist.list}" var="stu">
<c:forEach items="${cp}" var="stu1" varStatus="x">
<c:if test="${stu.id==cp[x.index][0]}">
<tr>
<td width="40%" height="35" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${stu.company_name}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][1]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][2]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][3]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][4]}</td>
</tr>
</c:if>
</c:forEach>
</c:forEach>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------lele debug1.0
List<Company> qylist = companyService.getAll();
List<Pingyi> pylist;
cp = new String[qylist.size()][5];
for(int j = 0;j<qylist.size();j++){
cp[j][0] = qylist.get(j).getId()+"";
cp[j][1] = "0";
cp[j][2] = "0";
cp[j][3] = "0";
cp[j][4] = "0";
pylist = pingyiService.findByProperty("company_id",qylist.get(j).getId()+"");
for (int i = 0; i < pylist.size(); i++) {
if (pylist.get(i).getManyidu().equals("非常满意")) {
cp[j][1] = (Integer.parseInt(String.valueOf(cp[j][1]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("满意")){
cp[j][2] = (Integer.parseInt(String.valueOf(cp[j][2]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("一般")){
cp[j][3] = (Integer.parseInt(String.valueOf(cp[j][3]))+1)+"";
}else if(pylist.get(i).getManyidu().equals("不满意")){
cp[j][4] = (Integer.parseInt(String.valueOf(cp[j][4]))+1)+"";
}
}
System.out.println("企业编号:"+cp[j][0]+"满意度调查:");
System.out.println(""+cp[j][1]+"|"+cp[j][2]+"|"+cp[j][3]+"|"+cp[j][4]+"|");
} -----------------------------------------------------------------------------------------------------------------------------------------------------------------
页面
<c:forEach items="${clist.list}" var="stu">
<c:forEach items="${cp}" var="stu1" varStatus="x">
<c:if test="${stu.id==cp[x.index][0]}">
<tr>
<td width="40%" height="35" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${stu.company_name}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][1]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][2]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][3]}</td>
<td width="15%" align="center" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #eeeeee;">${cp[x.index][4]}</td>
</tr>
</c:if>
</c:forEach>
</c:forEach>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------lele debug1.0
相关文章推荐
- 网站代码优化--应该正6确使用HTML标记
- 使用css sprites来优化你的网站在Retina屏幕下显示实现原理与代码
- iOS性能优化之内存管理:Analyze、Leaks、Allocations的使用和案例代码
- Android代码优化——使用Android lint工具
- 使用正则表达式优化网页代码
- 【代码优化】考虑使用静态工厂方法取代构造器
- 使用内部和匿名类优化Java代码
- 如果网站优化不再使用或需要外链建设
- 利用多域名存储静态资源进行性能优化:网站的静态资源为什么要使用独立域名
- 不修改代码就能优化ASP.NET网站性能的一些方法
- 在使用Reference Source调试.Net 源代码时如何取消optimizations(代码优化)-翻译
- 如何使用dispatch_once优化代码性能
- 爬虫代码实现二:抽取网站规则模板,优化解析代码(2)
- eclipse使用技巧3——优化调试代码
- Django代码性能优化与Pycharm Profile使用详解
- ASP.NET MVC 3 网站优化总结(一) 使用 Gzip 压缩
- android studio使用git第一次配置并上传代码到码云
- 二代旅游网站CMS使用手册(七):网站优化推广管理
- 【代码优化】当许多构造函数的参数,请考虑使用builder模式