您的位置:首页 > 编程语言 > Java开发

Struts标签iterator嵌套用法,及相关属性详解

2016-06-30 20:33 459 查看
<%@ page contentType="text/html; charset=UTF-8"%>

<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<!-- 要在jsp页面使用struts标签,需要导入 -->

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>课程信息</title>
</head>
<body>
<form id="form1id" name="form1id" method="post" action="userTable.action?action=saveOrUpdateObject"></form>
<!-- Form 对象属性:id 设置或返回表单的id,name设置或返回表单的名称,method 属性可设置或返回用于表单提交的 HTTP 方法。 
action 属性定义了当表单被提交时数据被送往何处。target 属性可设置或返回在何处打开表单中的 action-URL-->
<div class="cardTab" id="tableDiv">
<s:set name="rowIndex" value='1'></s:set>
<!-- 给索引赋值 -->
<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-top:#d8d8d8 solid 1px;">

<!-- 表头 -->
<tr class="tb-head" style="width:988px">
<td style="width:141px">序号</td>
<td style="width:141px">一级</td>
<td style="width:141px">二级</td>
<td style="width:141px">三级</td>
</tr>
<!-- 一级菜单 -->
<tr>
<td  style="width:141px"><label><s:property value="#rowIndex" /></label></td>
<!-- value=#rowIndex输出rowIndex的值 -->
<td  style="width:141px"><s:property value="level1vo.moduleName"/></td>
<!-- 若是对象,如level1vo,则不用遍历,直接取值即可 取值方法:<s:property value="level1vo.moduleName"/>-->
<td  style="width:141px"><label></label></td>
<td  style="width:141px"><label></label></td>
</tr>
<!-- 二级菜单,一级嵌套 -->
<s:iterator value="level1vo.subRMVOList" id="entry2" status="st2">
<!-- 嵌套时直接用一级对象调用,并赋给id属性一个实体对象“entry” ,用于调值,在调值的时候前边一定要加#号。-->
<s:set name="rowIndex" value='#rowIndex+1'></s:set>
<tr>
<td  style="width:141px"><s:property value="#rowIndex" /> sdssd <s:property value="#st2.index" /></td>
<!-- status用于取索引值 -->
<td  style="width:141px"><label></label></td>
<td  style="width:141px"><label><s:property value="#entry2.moduleName"/></label></td>
<td  style="width:141px"><label></label></td>
</tr>

<!-- 三级菜单 -->
<s:iterator value="#entry2.subRMVOList" id="entry3" status="st3"> <!-- iterator标签属性,value取值对象或集合List,对象用value=“*”来取,集合用value=“%{List对象}”来取值-->
<s:set name="rowIndex" value='#rowIndex+1'></s:set>
<tr>
<td  style="width:141px"><label><s:property value="#rowIndex" /></label></td>
<td  style="width:141px"><label> </label></td>
<td  style="width:141px"><label> </label></td>
<td  style="width:141px"><label><s:property value="#entry3.moduleName"/></label></td>
</tr>
</s:iterator>
</s:iterator>
</table>
</div>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struts 标签