0
我在我的jsp页面中有一个HTML表格。这包含了文本字段和一个下拉框。 从我的servlet中,我想传递一个名为myData
的字符串数组列表。迭代arraylist并通过jstl将值传递给整个表格
所以我尝试使用的foreach将数据传输到我的HTML表格:
<table border="1" >
<c:forEach items="${myData}" var="result">
<tr>
<td><input name="from0" type="text" value="${result}"/></td>
</tr>
<tr>
<td>
<select name="from8" id="from8" value="${result}">
<option>Yes</option>
<option>No</option>
</select>
</td>
</tr>
</c:forEach>
</table>
ArrayList的是一个简单的字符串数组列表:
ArrayList<String> output = new ArrayList<String>();
//populate arraylist with values here
//forward the arraylist of strings
request.setAttribute("myData ", output);
request.getRequestDispatcher("Home.jsp").forward(request, response);
不幸的是结果,产生多个表,它们的值全部对应于我的数组列表中的每个元素。
猜测数组列表的结构是很困难的。你可以发布你的结构吗? – reporter
@reporter我编辑了这个问题,添加了数组列表结构 – user571099