1: Use Jstl tags (can be used with custom tags)
First refer to Jstl label
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
Then use the foreach label
<c:foreach items= "${list}" var= "user" varstatus= "vs" >
<tr>
<td>
<s:property value = "#vs. Index+1"/>
</td>
<td align = "center" >${user. Pid}</td>
<td align = "center" >${user. Ploginname}</td>
<td align = "center" >${user. Pusername}</td>
<td align = "center" >${user. Pemail}</td>
<td align = "center" >
You can use <c:if test= "${not Empty list}" ></c:if> and <c:if test= "${not Empty list}" ></c:if> to handle null cases. If not null, display values, empty words, show no records, and so on.
The background can put the list to the value stack or to the request. For example: Request.setattribute ("list", xxxxlist);
2: Use JSP inline Java code traversal list (in the background of the list into the session, if it is a large amount of data, should not use this method)
First in the background to put the list into the session
Request.getsession (). setattribute (data.allnewslist, list);
The red Mark Data.allnewslist is defined as a constant in the data class under the Com.xiami.onlineshop.common package
public static final String allnewslist= "Allnewslist";
JSP Code: (Note the red code do not forget to introduce the corresponding class)
<%@ page language= "java" import= "Java.util.*,com.xiami.onlineshop.common.*,com.xiami.onlineshop.data.*" pageencoding= "GBK"%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
3: Use Struts tab
<%@ taglib prefix= "s" uri= "/struts-tags"%>
<s:iterator value= "#request. UserList" status= "stat" id= "SD" >
<tr align= "center" >
<td>
<s:property value= "#sd [6]"/>
</td>
<td>
<s:property value= "#sd [1]"/> </td>
<td>
<s:property value= "#sd [2]" ></s:property>
</td>
<td>
<s:property value= "#sd [4]" ></s:property>
</td>
<td>
< S:property value= "#sd [5]" ></s:property>
</td>
</tr>
</s:iterator>