JSP 利用<c>循环构建table行 循环嵌套
页面代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%=path%>/jQuery/jquery-1.12.4.js"></script>
<script type="text/javascript" src="<%=path%>/jQuery/showa1.js"></script>
<link rel="stylesheet" href="<%=path%>/css/showa1.css" type="text/css" />
</head>
<body>
<div class="showinfo">
<span>系统管理:用户管理</span>
</div>
<div id="main">
<div id="table">
<table id="tablemax" cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">
<tr>
<th style="min-width: 33px;"><input type="checkbox" /></th>
<th style="width: auto;">姓名</th>
<th style="min-width: 100px;">角色</th>
<th style="min-width: 200px;">权限</th>
<th style="min-width: 40px;">编辑</th>
</tr>
<!--循环代码加载此处-->
</table>
</div>
<div id="operation">
<input style="margin-left: 45px;" class="but" type="button" value="删除" id="del">
<input class="but" type="button" value="添加" id="insert">
<a href="javascript:void(0);" style="margin-left: 50px;"> <<<< </a>
<a href="javascript:void(0);"> << </a>
<a href="javascript:void(0);"> >> </a>
<a href="javascript:void(0);"> >>>> </a>
<span style="margin-left: 15px;">页次:<span id="pageNow"></span></span>
<span id="into">转至:<input type="text"></span><input id="go" class="but" type="button" value="Go>>">
</div>
</div>
</body>
</html>
<c:forEach items="${list}" var="user">
<tr><td><input type="checkbox" /></td>
<td>${user.realname}</td>
<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">
<c:forEach items="${user.listRole}" var="role">
<tr><td>${role.rolename}</td></tr>
</c:forEach>
</table></td>
<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">
<c:forEach items="${user.listRole}" var="role">
<tr><td>
<c:forEach items="${role.listModule}" var="module">
${module.modulename}
</c:forEach></td></tr>
</c:forEach>
</table></td>
<td>编辑</td>
</tr>
</c:forEach>