关于如何使用struts标签输出值为map的list

最近在一个项目中,要将一个list在客户端输出,而list里面的每个值不是bean,而是map,想好好久,想了个办法,可以实现,代码如下

  ArrayList  testList=new ArrayList();  HashMap testMap1=new HashMap();  testMap1.put("grade","七年级");  testMap1.put("class","一班");  testMap1.put("master","张三");  testList.add(testMap1);  HashMap testMap2=new HashMap();  testMap2.put("grade","八年级");  testMap2.put("class","二班");  testMap2.put("master","张三");  testList.add(testMap2);  HashMap testMap3=new HashMap();  testMap3.put("grade","九年级");  testMap3.put("class","五班");  testMap3.put("master","李四");  testList.add(testMap3);

    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#0033CC" name="tableList">     <tr><td>master</td><td>class</td><td>grade</td></tr>            <logic:iterate id="element" indexId="ind" name="testList" >             <tr>                   <td>         <logic:iterate id="elementValue" indexId="idx" name="element">       <logic:equal name="elementValue" property="key" value="master">                    <bean:write name="elementValue" property="value"/>                     </logic:equal>      </logic:iterate>      </td>                                    <td> <logic:iterate id="elementValue" indexId="idx" name="element">      <logic:equal name="elementValue" property="key" value="class">                    <bean:write name="elementValue" property="value"/>                    </logic:equal>     </logic:iterate>     </td>                        <td><logic:iterate id="elementValue" indexId="idx" name="element">        <logic:equal name="elementValue" property="key" value="grade">                    <bean:write name="elementValue" property="value"/>                    </logic:equal>     </logic:iterate>       </td>            </tr>            </logic:iterate>    </table>
masterclassgrade还有更好的方法,欢迎交流,第一次在blog上发文,没有排版,请多见谅!

时间: 2024-09-15 19:33:17

关于如何使用struts标签输出值为map的list的相关文章

struts标签取值问题

问题描述 如何在迭代里获取codeId=2 解决方案 解决方案二:后台代码是:packagecom.yumdou.code.action;importjava.util.ArrayList;importjava.util.List;importcom.yumdou.code.action.base.HomeAction;importcom.yumdou.code.entity.CodeVO;publicclassToCreateActionextendsHomeAction{privateLis

struts-怎样用Struts标签取出errors中的内容

问题描述 怎样用Struts标签取出errors中的内容 解决方案 以上说的都不是我要的答案,这个问题我已经解决 解决方案二: 既然是user.,那说明你有那样的实体.所以你需要有对应的set,get方法,然后在对应的页面上添加该字段,根据struts,能够获取到你传输的对应信息 解决方案三: 你是要使用哪个标签struts标签输出...迭代显示errors所有内容 /s:iterator

关于struts的select标签回值给formbean的一个问题

问题描述 向大家请教一个关于struts的select标签回值给formbean的一个问题.我通过select标签已将hibernate关联查询出的UserVo封装的userList显示出来了.事例代码:<logic:iterateid="userInfo"name="userInfoForm"property="userInfoList"><html:selectproperty="groupVo.groupid&q

浅谈Struts标签logic:iterate

< logic:iterate >是Logic Struts标签库中最复杂的标签,也是用途最广的一个标签,它能够 在一个循环中遍历数组.Collection.Enumeration.Iterator 或 Map 中的所有元素. 1. 遍历集合 的 name 属性指定需要进行遍历的集合对象, 它每次从集合中检索出一个元素, 然后把它放在page 范 围内, 并以id 属性指定的字符串来命名这个元素, 例如: < % Vector animals = new Vector(); animal

强制解析html标签-如何强制页面解析HTML标签属性值里面的标签???求大神赐教,解析这个title里面的标签,谢谢!

问题描述 如何强制页面解析HTML标签属性值里面的标签???求大神赐教,解析这个title里面的标签,谢谢! <button id="emoji-id" type="button" class="btn btn-default emoji" title="<table border='1'><tr><th>Heading</th><th>AnotherHeading<

struts标签-struts下的jsp文件中html:select 下的各个属性有哪些

问题描述 struts下的jsp文件中html:select 下的各个属性有哪些 struts下的jsp文件中html:select 下的属性property,styleIdonchange分别是什么意思啊这行struts的jsp代码是什么意思,哪位朋友能说一下,十分感谢 解决方案 1.property 是 ActionForm里定义的变量,就相当于html标签里面的name属性如 被解析后和html语句是一样的只是用了struts的property属性就得有想对应formBean,否则报错.2

对象-怎么样用struts标签传递一个long到action?

问题描述 怎么样用struts标签传递一个long到action? <s:textfield name="police.id" /> 类型不一致报错. 因为在action中直接是一个实体对象police接收数据,其中id类型是long.也就是police.id为long类型 怎么使用struts标签传递long数据到police.id中. 解决方案 用struts的模型驱动传递数据的方式有: 一:动作类充当模型驱动: 1.在动作类提供id的set方法,struts会为你自动

struts标签&amp;lt;s:date&amp;gt;的使用

  最近研究struts时,发现这个标签能够解决很多格式上的问题,所以在网上搜索了一下这个内容,发现这篇文章写得挺不错的,挺有收获. struts 标签 :<s:date/> 作用:用来格式化显示日期的格式.   它可以用一种你指定的格式来显示(如:"yyyy-MM-dd"),可以生成通俗易懂的注释(如:in 2 hours,14 minutes),或者用预先定义的一个格式来显示(如在properties配置文件中配置'struts.date.format').如果没有找到

struts标签嵌套的问题

问题描述 <s:set value="#request.actionMessage" name="obj" scope="request"></s:set>alert('<s:property value="#request.obj"/>');alert('${obj}');前面几行都是正确的,我是想通过obj这个参数去国际化配置文件中捞值下面的写法在2.18中报错,不允许标签中嵌套<