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