我很新的春天,我試圖使用Spring MVC + JSP + JSTL。我的目標是使JSP包含用戶列表並允許單獨編輯每個用戶。因此,我認爲我應該使用單獨的<form>
標籤和獨立<sumbit>
按鈕對列表中的每一個用戶,我的JSP的樣子:使用<form>內<foreach>幾次
<c:forEach items="${userList}" var="currentUser" varStatus="index">
<form:form method="post" action = "edit" commandName="userList[${index}]">
<tr>
<td><form:input path = "userList[${index}].login" value = "${currentUser.login}" /></td>
<td><form:input path = "userList[${index}].password" value = "${currentUser.password}" /></td>
<td><form:input path = "userList[${index}].smtpServer" value = "${currentUser.smtpServer}" /></td>
<td><form:input path = "userList[${index}].popServer" value = "${currentUser.popServer}" /></td>
<form:hidden path="userList[${index}].id" value=""/>
<td>
<a href="delete/${user.id}"><spring:message code="label.delete" /></a>
</td>
</tr>
<input type="submit" value = "edit">
</form:form>
</c:forEach>
的想法是通過按下按鈕分別有編輯每個用戶有機會「編輯」。當然這個代碼不起作用。它給了我一個例外:
java.lang.IllegalStateException:無論BindingResult也不是爲bean名稱「用戶列表[使用javax」可以作爲要求 屬性平原 目標對象
我真的完全小白在春季和網絡編程也是如此。我會感謝任何幫助。
這是因爲我是noob :)謝謝!你是正確的!所以不是所有的工作!謝謝 :) –