[“ A”,“ B”,“ C”,“ D”,“ E”,“ F”]-ArrayList 01
[1,2,3,4,5,6]-ArrayList 02
[10,20,30,40,50,60]-ArrayList 03
[100,200,300,400,500,600]-数组列表04
Main_List-[[[“ A”,“ B”,“ C”,“ D”,“ E”,“ F”],[1,2,3,4,5,6],[10,20,30, 40,50,60],[100,200,300,400,500,600]];
Main_List是四个数组列表的组合 如何将Main_List检索到具有四列的表中?
<c:forEach items="${List_parameter}" var="post" varStatus="theCount">
<tbody>
<c:forEach items="${post}" var="value" varStatus="cell">
<tr>
<td scope="row">${theCount.count}</td>
<td>${value.get(0)}</td>
<td>${value.get(1)}</td>
<td>${value.get(2)}</td>
<td>${value.get(3)}</td>
<td>-</td>
</tr>
</c:forEach>
</tbody>
</c:forEach>
Servlet将列表传递给JSP
Scanner scanner = new Scanner(Result);
ControlData controlData = new ControlData();
while(scanner.hasNextLine())
{
token1 = scanner.nextLine();
Wtcs = controlData.CtrlWeight(token1);
NC = controlData.NofConditions(token1);
Ccspps = controlData.previousComplex(token1);
cdLine.add(token1);
wtc.add(Ccspps);
ncc.add(NC);
ccpps.add(Wtcs);
}
List arr[]={cdLine,wtc,ncc,ccpps};
scanner.close(); //close the scanner
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/views/Control_structures.jsp");
request.setAttribute("Code_string", arr);
dispatcher.forward(request, response);
}
```
问题来源:Stack Overflow
我得到了我问题的答案。
在servlet中
Scanner scanner = new Scanner(Result);
ControlData controlData = new ControlData();
List<List<Comparable>> p =new ArrayList<List<Comparable>>();
while(scanner.hasNextLine())
{
token1 = scanner.nextLine();
Wtcs = controlData.CtrlWeight(token1);
NC = controlData.NofConditions(token1);
Ccspps = controlData.previousComplex(token1);
List<Comparable> c =new ArrayList<Comparable>();
c.add(token1);
c.add(Wtcs);
c.add(NC);
c.add(Ccspps);
p.add(c);
}
scanner.close(); //close the scanner
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/views/jsp_page.jsp");
request.setAttribute("Code_string", p);
dispatcher.forward(request, response);
现在,我有一个简单的列表来传递JSP。
<c:forEach items="${Code_string}" var="post" varStatus="theCount1">
<tbody>
<tr>
<td>${post[0]}</td>
<td>${post[1]}</td>
<td>${post[2]}</td>
<td>${post[3]}</td>
</tr>
</tbody>
</c:forEach>
回答来源:Stack Overflow
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。