首页 > 代码库 > struts2知识汇总
struts2知识汇总
标签遍历Map<key,List<Object>>
listMap=new HashMap<String,List<Student>>(); List<Student> list1=new ArrayList<Student>(); list1.add(new Student(new Long(1),"20034140201","张三1","男",25)); list1.add(new Student(new Long(2),"20034140202","张三2","男",25)); list1.add(new Student(new Long(3),"20034140203","张三3","男",25)); listMap.put("class1", list1); List<Student> list2=new ArrayList<Student>(); list2.add(new Student(new Long(1),"20034140301","李四1","男",20)); list2.add(new Student(new Long(2),"20034140302","李四2","男",21)); list2.add(new Student(new Long(3),"20034140303","李四3","男",22)); list2.add(new Student(new Long(4),"20034140304","李四4","男",23)); listMap.put("class2", list2);
<s:iterator value="listMap" id="column"> <s:set name="total" value="#column.value.size"/> <s:iterator value="#column.value" status="s"> <tr> <s:if test="#s.first"><td rowspan="${total}"><s:property value="#column.key"/></td></s:if> <td><s:property value="id"/></td> <td><s:property value="num"/></td> <td><s:property value="name"/></td> <td><s:property value="sex"/></td> <td><s:property value="age"/></td> </tr> </s:iterator> </s:iterator>
struts2配置文件,重定向action并传真
<action name="updateCampaign" class="campaignAction" method="updateCampaign"> <result name="success" type="redirectAction"> <param name="actionName">viewCampaignDetail</param> <param name="campaignId">${campaignId}</param> </result> </action>
struts接收数组
publicclass A { private String param[]; public String[] getParam() { returnparam; } publicvoid setParam(String[] param) { this.param = param; } publicvoid execute(){ for(int i=0;i<this.param.length;i++){ System.out.println(this.param[i]); } }}
参考链接
http://blog.csdn.net/hakunamatata2008/article/details/5295500
http://blog.csdn.net/shen516/article/details/10111677
struts2知识汇总
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。