0
내 JSP 페이지에 HTML 테이블이 있습니다. 텍스트 필드와 드롭 다운 상자가 있습니다. 서블릿에서 myData
이라는 문자열의 arraylist를 전달하고 싶습니다.arraylist를 반복하고 jstl을 통해 전체 테이블에 값을 전달하십시오.
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);
불행하게도 출력 값 여러 테이블을 생성합니다
<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를은 다음과 같습니다
그러므로 내 HTML 테이블에 데이터를 전송하는 foreach 문을 사용하려고 모두 내 arraylist의 각 요소에 해당합니다.
배열 목록의 구조를 추측하는 것은 어렵습니다. 당신의 구조를 게시 할 수 있습니까? – reporter
@reporter 질문을 편집하고 arraylist 구조체를 추가했습니다. – user571099