jsp ページに HTML テーブルがあります。これには、テキスト フィールドとドロップダウン ボックスが含まれます。サーブレットから、 という文字列の配列リストを渡したいと思いますmyData
。
したがって、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);
残念ながら、出力では複数のテーブルが生成され、その値はすべて配列リストの各要素に対応しています。