Struts2学习笔记集锦

来源:互联网 发布:悉知和知悉有什么区别 编辑:程序博客网 时间:2024/06/05 09:44

 

参考

http://www.blogjava.net/tinguo002/archive/2012/07/26/384097.html

http://www.cnblogs.com/xly1208/archive/2011/11/19/2255500.html

 

struts2标签表达式一般只认name和value属性,遇到这些属性会自动替换,对于其他属性,默认不处理,所以需要强制其处理,用%{}号标记

 

<s:iterator id="abc" value="abc.person" var="person" status="status">
         <tr>
          <td><s:property value="#status.count"/></td>
          <td><input type="checkbox" /></td>
          <td><s:property value="pName"/></td>
          <td><s:if test="type==0">
           成人
           </s:if>
           <s:elseif test="type=1">
           儿童
           </s:elseif>
           <s:else>
           婴儿
           </s:else>
          </td>
          <s:iterator id="cccs" value="cccs" var="ccc" status="status">
           <td>
            <s:if test="statusMap[personNo][#ccc] == 0">
             <s:checkbox fieldValue="%{personNo}" ></s:checkbox>
            </s:if>
            <s:else>
             <s:checkbox fieldValue="%{#ccc}" ></s:checkbox>
            </s:else>
           </td>
          </s:iterator>
         </tr>
        </s:iterator>

 

其中,pName,type,personNo是属于person的属性

 

后台struts2的action存储为:

private ArrayList<String> cccs;
 private Map<String,Map<String, Integer>> statusMap= new HashMap<String, Map<String,Integer>>(); //ticketno,flight,status

 

其中statusMap在前台展示为:statusMap[personNo][#ccc]取值。对于对象的属性引用,可以直接用属性值代替,,如pName,type,personNo,对本身的引用,需要前面加#号。,如#ccc方能识别。

 


 

原创粉丝点击