//定义listpojo用于存放pojo类
List listpojo = new ArrayList();
//实例化一个pojo类
Pojoceshi pojo = new Pojoceshi();
pojo.setName("济南");
//定义listfood用于存放食物
List listfood = new ArrayList();
String food = null;
food = "香蕉";
listfood.add(food);
food = null;
food = "橘子";
listfood.add(food);
food = null;
pojo.setList_food(listfood);
listpojo.add(pojo);
pojo = null;
//实例化一个pojo类
Pojoceshi pojo2 = new Pojoceshi();
pojo2.setName("青岛");
//定义listfood用于存放食物
List listfood2 = new ArrayList();
String food2 = null;
food2 = "香蕉";
listfood2.add(food2);
food2 = null;
food2 = "橘子";
listfood2.add(food2);
food2 = null;
pojo2.setList_food(listfood2);
listpojo.add(pojo2);
pojo2 = null;
//实例化一个pojo类
Pojoceshi pojo3 = new Pojoceshi();
pojo3.setName("马鞍山");
//定义listfood用于存放食物
List listfood3 = new ArrayList();
String food3 = null;
food3 = "香蕉";
listfood3.add(food3);
food3 = null;
pojo3.setList_food(listfood3);
listpojo.add(pojo3);
pojo3 = null;
%>
My JSP 'index.jsp' starting page名称 | 食物 |
Pojoceshi pojo888 = null;
for (int i = 0; i < listpojo.size(); i++) {
pojo888 = listpojo.get(i);
int j = pojo888.getList_food().size();
%>
for (int ii = 0; ii < j; ii++) {
if (ii == 0) {
%>
} else {
System.out.print("shuliang" + ii);
%>
}
}
pojo888 = null;
}
%>
DTO类
package test;
import java.util.ArrayList;
import java.util.List;
public class Pojoceshi {
private String name;
private List list_food;
//=new ArrayList();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List getList_food() {
return list_food;
}
public void setList_food(List list_food) {
this.list_food = list_food;
}
}
以上只是简单的合并一列! 假如有如下业务
要显示的字段有公司,部门,子部门,职员,薪水!
以公司,部门,子部门来合计有多少职员,总工资是多少!
其实也很简单!
分享到:
2014-04-15 23:21
浏览 3992
评论