Home > Web Front-end > HTML Tutorial > Struts nested traversal_html/css_WEB-ITnose

Struts nested traversal_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:02:26
Original
1213 people have browsed it

设计菜单实体类如下:

public class Menu implements Serializable {        private int id;	private String menuName; // 菜单名称	private String menuUrl; // 菜单url	private int menuParent; // 父菜单编号	private List<Menu> children;// 子菜单}
Copy after login

????????????????????????????????????????????????????
在jsp如何使用Struts标签遍历显示:
我的代码:
<!-- 菜单开始 --><s:iterator id="menu" value="menus">	<h1><s:property value="menuName" /></h1><!--一级菜单,测试通过-->		<div class="content">			<ul class="MM">				<s:iterator id="subMenu" value="#menu.children" /><!--二级菜单,现在就是二级菜单遍历有误,页面编译不通过-->					<li><a href="http://www.865171.cn" target="main"><s:property value="subMenu.menuName" /></a></li>				</s:iterator>			</ul>		</div></s:iterator><!-- 菜单结束 -->  
Copy after login


回复讨论(解决方案)

错误是:org.apache.jasper.JasperException: /menu.jsp(177,3) The end tag "</s:iterator" is unbalanced

menus 你迭代它?没看到list定义为menu的

menus 你迭代它?没看到list定义为menu的


使用for循环遍历可以,但是使用s标签不可以,麻烦帮忙看下标签哪里有错误。
<!-- 菜单开始 -->    <%	List<Menu> ml = (List<Menu>)request.getAttribute("menus");	System.out.println("*************pan****************:"+ml);	for(int i = 0; i < ml.size(); i++){	%>	<h1 class="type"><a href="javascript:void(0)"><%=ml.get(i).getMenuName() %></a></h1>	<div class="content">		<table width="100%" border="0" cellspacing="0" cellpadding="0">		<tr>			<td><img src="images/menu_topline.gif" width="182" height="5" /></td>		</tr>		</table>		<ul class="MM">	<%	System.out.println("一:");	for(int j = 0; j < ml.get(i).getChildren().size(); j++){	%>		<li><%=ml.get(i).getChildren().get(j).getMenuName() %></li>	<%		}	%>	</ul>	</div>	<%	}	%>	<!-- 菜单结束 -->
Copy after login

最终也没有用Struts标签实现,淡淡的忧伤。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template