jsp:将后台取得的list遍历到表格里,为什么我的一行是一个表格了呢?
<html><head></head><body><%List<DataForm>list=newArrayList<DataForm>();PublicDaodao=n...
<html>
<head>
</head>
<body>
<%
List<DataForm> list = new ArrayList<DataForm>();
PublicDao dao = new PublicDao();
DataForm form = new DataForm();
if(request.getAttribute("list")!=null)
list=(List)request.getAttribute("list");
list = dao.getAllData(1,2);
System.out.println("-----------------index.jsp----------------");
System.out.println("list的size"+list.size());
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<table border="1">
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%
}
%>
</table>
<table>
<tr><td><%=basePath%>Servlet?page=1&pagesize=2</td><tr>
<tr><td><a href="<%=basePath%>Servlet?page=1&pagesize=2" >首页</a></td><td><a href="<%=basePath%>Servlet?page=1&pagesize=2">末页</a></td><tr>
</table>
</body>
</html> 展开
<head>
</head>
<body>
<%
List<DataForm> list = new ArrayList<DataForm>();
PublicDao dao = new PublicDao();
DataForm form = new DataForm();
if(request.getAttribute("list")!=null)
list=(List)request.getAttribute("list");
list = dao.getAllData(1,2);
System.out.println("-----------------index.jsp----------------");
System.out.println("list的size"+list.size());
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<table border="1">
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%
}
%>
</table>
<table>
<tr><td><%=basePath%>Servlet?page=1&pagesize=2</td><tr>
<tr><td><a href="<%=basePath%>Servlet?page=1&pagesize=2" >首页</a></td><td><a href="<%=basePath%>Servlet?page=1&pagesize=2">末页</a></td><tr>
</table>
</body>
</html> 展开
3个回答
展开全部
你在遍历什么东西??遍历表格还是遍历行??
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<table border="1">
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%
}
%>
</table>
这个遍历问题的。。你要么就遍历整个表格,要么就遍历行,,
<table border="1">你可以把这个放到前面去。。要么
<%
}
%>
放到</table>后面
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<table border="1">
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%
}
%>
</table>
这个遍历问题的。。你要么就遍历整个表格,要么就遍历行,,
<table border="1">你可以把这个放到前面去。。要么
<%
}
%>
放到</table>后面
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<table border="1">放在for循环前面试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-06-21
展开全部
<table border="1">
<%
List<DataForm> list = new ArrayList<DataForm>();
PublicDao dao = new PublicDao();
DataForm form = new DataForm();
if(request.getAttribute("list")!=null)
list=(List)request.getAttribute("list");
list = dao.getAllData(1,2);
System.out.println("-----------------index.jsp----------------");
System.out.println("list的size"+list.size());
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%}%>
</table>
<%
List<DataForm> list = new ArrayList<DataForm>();
PublicDao dao = new PublicDao();
DataForm form = new DataForm();
if(request.getAttribute("list")!=null)
list=(List)request.getAttribute("list");
list = dao.getAllData(1,2);
System.out.println("-----------------index.jsp----------------");
System.out.println("list的size"+list.size());
for (int i = 0; i < list.size(); i++) {
form = list.get(i);
%>
<tr>
<td><%=form.getROLEID()%></td>
<td><%=form.getROLECAPTION()%></td>
<td><%=form.getROLECODE()%></td>
<td><%=form.getROLEDESC()%></td>
<td><%=form.getCREATEOPERATORID()%></td>
<td><%=form.getMODIFYOPERATORID()%></td>
<td><%=form.getCREATEDATE()%></td>
<td><%=form.getMODIFYDATE()%></td>
<td><%=form.getDELSIGN()%></td>
</tr>
<%}%>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询