我想问一下当我使用ACTIONForm单击SAVE按钮时,如何在循环内的jsp表单中检索同名的值,而不使用request.getParameterValues(“screenName”)的struts中的Action类。
以下是我想从循环内部检索名称“screenName”的示例jsp代码:
<form action="EditScreeningServlet" method="post">
<input type = "hidden" name ="applicantNumber" value="${infoObj.applicantNumber}" >
<table>
<c:forEach var="screen" items="${screenList}">
<input type = "hidden" name ="screenId" value="${screen.screenId}" >
<tr>
<td>Screen Type:  </td> <td>*<input type="text" value="${screen.screenName}" name="screenName" readonly ="true">*</td>
</tr>
<tr>
<td>Date: </td> <td><input type="text" value="${screen.screenDate}" name="screenDate" class="date"></td>
</tr>
<tr>
<td>Result: </td>
<td>
<select name = screenResult>
<option value="Pass" ${screen.screenResult == 'Pass' ? 'selected' : ''}>Pass</option>
<option value="Fail" ${screen.screenResult == 'Fail' ? 'selected' : ''}>Fail</option>
<option value="" ${screen.screenResult == '' ? 'selected' : ''}></option>
</select>
</td>
</tr>
<tr><td> </td><td>  </td></tr>
</c:forEach>
</table>
<input type="submit" class="saveButton" value="SAVE">
</form>
答案 0 :(得分:0)
在<form>
中你无法获得输入元素数组,但你可以。
<c:forEach var="screen" varStatus="loopStatus" items="${screenList}">
<input type = "hidden" name ="screenId" value="${screen.screenId}" >
<tr>
<td>Screen Type: </td>
<td>*<input type="text" value="${screen.screenName}" name="screenName${loopStatus.count}" readonly ="true">*</td>
</tr>
</c:forEach>
或者您可以使用ID与input text element
<c:forEach var="screen" varStatus="loopStatus" items="${screenList}">
<tr>
<td>Screen Type: </td>
<td>*<input type="text" value="${screen.screenName}" name="screenName${screen.screenId}" readonly ="true">*</td>
</tr>
</c:forEach>