0
我正在嘗試將Java類文件上的ArrayList迭代到jsp文件以顯示錶格格式的輸出。將java中的映射迭代爲jsp
JSP文件:
<jsp:useBean id="mybean3" class="org.mypackage.process" scope="session" >
<jsp:setProperty name="mybean3" property="type" value="CARRIER DATA FILES" />
</jsp:useBean>
<table><tr><th>Header1</th> <th>Header2</th></tr>
<c:forEach items="${mybean3.values}" var="element3">
<tr> <td><c:out value="${element3.DISTTT}" /></td>
<td><c:out value="${element3.MESS}" /></td></tr>
</c:forEach>
Java類文件:
public void setType(String typecol) {
mpp= new HashMap();
abc = new ArrayList();
this.typecol = typecol;
for (int j=0;j<=5;j++){
mpp.put("DISTTT",j);
mpp.put("MESS",j);
abc.add(mpp);
}
}
public ArrayList getValues(){
Object ob;
this.Values = abc;
return Values;
}
期待O/P:
Header1 Header2
1 1
2 2
3 3
4 4
5 5
當前O/P:
Header1 Header2
5 5
5 5
5 5
5 5
5 5
[JSTL(http://tomcat.apache.org/taglibs/)是你的朋友 – hd1 2013-05-12 17:20:48