如果记录集为一个List,List中是一堆数组String[]
<table border="1">
<c:forEach items="${array}" var="aa">
<c:set value="aa" var="bb" />
<tr><td>
<c:forEach items="aa" var="bb">
<c:out value="${bb}"/>
</c:forEach>
</td></tr>
</c:forEach>
</table>
我这样做是不成功的!!!
请教应该怎么来写?
List mList = new ArrayList();
String[] array = {"winter", "spring", "summer", "fall"};
mList.add(array);
String[] array1 = {"winter1", "spring1", "summer1", "fall1"};
mList.add(array1);
String[] array2 = {"winter2", "spring2", "summer2", "fall2"};
mList.add(array2);
session.setAttribute("array", mList);
<table border="1">
<c:forEach items="${array}" var="aa">
<c:set value="aa" var="bb" />
<tr><td>
<c:forEach items="aa" var="bb">
<c:out value="${bb}"/>
</c:forEach>
</td></tr>
</c:forEach>
</table>
我这样做是不成功的!!!
请教应该怎么来写?
List mList = new ArrayList();
String[] array = {"winter", "spring", "summer", "fall"};
mList.add(array);
String[] array1 = {"winter1", "spring1", "summer1", "fall1"};
mList.add(array1);
String[] array2 = {"winter2", "spring2", "summer2", "fall2"};
mList.add(array2);
session.setAttribute("array", mList);
<jsp:forward page="ii.do"></jsp:forward>servlet中:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if(request.getRequestURI().endsWith("ii.do")){
HttpSession session = request.getSession();
List mList = new ArrayList();
String[] array = {"winter", "spring", "summer", "fall"};
//String array = "one";
mList.add(array);
String[] array1 = {"winter1", "spring1", "summer1", "fall1"};
//String array1="two";
mList.add(array1);
String[] array2 = {"winter2", "spring2", "summer2", "fall2"};
//String array2 = "three";
mList.add(array2);
session.setAttribute("array", mList); }
request.getRequestDispatcher("/show.jsp").forward(request, response);
}show.jsp中:<c:forEach items="${array}" var="aa">
<c:forEach items="${aa}" var="bb">
<c:out value="${bb}"></c:out>
</c:forEach>
</c:forEach>结果:
winter spring summer fall winter1 spring1 summer1 fall1 winter2 spring2 summer2 fall2
没什么问题,我测试了!