我得到HTTP状态400.客户端发送的请求在语法上不正确。我所做的只是将编辑表单保存到数据库中,但请求不要去saveApplication
方法。提供HTTP状态的Spring MVC表单400
以下是我的edit.jsp
:
<div align="center">
<h1>New/Edit Contact</h1>
<form:form action="saveApplication" method="post" modelAttribute="application">
<table>
<form:hidden path="applicationId"/>
<tr>
<td>Application Name:</td>
<td><form:input path="applicationName" /></td>
</tr>
<tr>
<td>Start Date:</td>
<td><form:input path="startDate" id="startDate"/></td>
</tr>
<tr>
<td>End Date:</td>
<td><form:input path="endDate" id="endDate"/></td>
</tr>
<tr>
<td>Projected StartDate:</td>
<td><form:input path="projectedStartDate" id="projectedStartDate"/></td>
</tr>
<tr>
<td>Projected EndDate:</td>
<td><form:input path="projectedEndDate" id="projectedEndDate"/></td>
</tr>
<tr>
<td>Current Action:</td>
<td><form:input path="currentAction" /></td>
</tr>
<tr>
<td>Comments:</td>
<td><form:input path="comments" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Save"></td>
</tr>
</table>
</form:form>
</div>
在我的控制器类了以下方法:
@RequestMapping(value = "/editApplication", method = RequestMethod.GET)
public ModelAndView editApplication(HttpServletRequest request) {
ModelAndView model = new ModelAndView();
int applicationId = Integer.parseInt(request.getParameter("id"));
ApplicationTO to = applicationService.getApplication(applicationId);
model.addObject("application", to);
model.setViewName("edit");
return model;
}
@RequestMapping(value = "/saveApplication", method = RequestMethod.POST)
public ModelAndView saveContact(@ModelAttribute ApplicationTO application) {
ModelAndView model = new ModelAndView();
applicationService.saveApplication(application);
model.setViewName("view");
return model;
}
我上面一个,其给HTTP状态试图404 -/saveApplication – ASR
其给予theurl像这样,当我提交的http://本地主机:8080/saveApplication(对于上述溶液中)和它不表示任何日志 – ASR
Spring使用强大的命名约定......你可以尝试在控制器内而不是应用程序中使用applicationId吗? – OEH