私は春にいくつかの機能をテストしています。私の目的は、テーブルからレコードを編集することです。以下は、既存のレコードをディスパッチするJSPコードです。春のリクエストが間違ったハンドラーになる:
<table border="1">
<tr>
<td>ID</td>
<td>First Name</td>
<td>Last Name</td>
<td>Telephone</td>
<td>Email</td>
<td></td>
<td></td>
</tr>
<c:forEach var="emp" items="${employees}">
<tr>
<td>${emp.id}</td>
<td>${emp.firstName}</td>
<td>${emp.lastName}</td>
<td>${emp.telephone}</td>
<td>${emp.email}</td>
<td><a href="<c:url value="getEmpForUpdate/${emp.id}" />">Update</a></td>
<td><a>Delete</a></td>
</tr>
</c:forEach>
</table>
私は上記のコードで使用しているハイパーリンクに問題があると思います。
<a href="<c:url value="getEmpForUpdate/${emp.id}" />">Update</a>
私がレコードをクリックすると、URLは以下のようになります。
http://localhost:9876/SpringAnnotationDemo_Tomcat/getEmpForUpdate/4
そのレコードを編集するための表示フォーム。以下は、レコードを編集するために使用している私のコードです。私は以下の http://localhost:9876/SpringAnnotationDemo_Tomcat/updateEmployee
のようにする必要がありますURLを入力してヒットしかしhttp://localhost:9876/SpringAnnotationDemo_Tomcat/getEmpForUpdate/updateEmployee
My controller method is like below
@RequestMapping(value="/updateEmployee",method = RequestMethod.POST)
public ModelAndView updateEmployeeUsingObject(@ModelAttribute Employee employee){
ModelAndView modelAndView = new ModelAndView();
System.out.println(employee.getId());
return modelAndView;
}
の下には、あなたが私を聞かせていただけますようにそれがあるから、上記で詳細を編集した後
<form:form method="POST" action="/updateEmployee">
<table>
<tr>
<td><form:label path="firstName">F Name</form:label></td>
<td><form:input path="firstName" /></td>
</tr>
<tr>
<td><form:label path="lastName">L Name</form:label></td>
<td><form:input path="lastName" /></td>
</tr>
<tr>
<td><form:label path="telephone">Phone</form:label></td>
<td><form:input path="telephone" /></td>
</tr>
<tr>
<td><form:label path="email">E-Mail</form:label></td>
<td><form:input path="email" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
私が間違っている場所を知っている。なぜURLが期待どおりでないのか。
のようなものを与えて助けてください私はこれについて。 Spirng MVCアプリケーション – Abdul