【发布时间】:2015-05-28 21:45:21
【问题描述】:
这是我的表格:
<form action="${pageContext.request.contextPath}/admin/editc" method="POST" id="editForm">
<input type="text" name="username" class="form-control" />
<input type="text" name="password" class="form-control" />
<input type="submit" value="submit" >
</form>
这是我的控制器方法:
@RequestMapping(value = "/admin/edit", method = RequestMethod.GET)
public ModelAndView editPage() {
ModelAndView model = new ModelAndView();
model.addObject("title", "User edit Form - Database Interaction");
model.addObject("message", "This page is for ROLE_ADMIN only!");
model.setViewName("editpage");
System.out.println("getting edit page");
return model;
}
@RequestMapping(value = "/admin/editc", method = RequestMethod.POST)
public ModelAndView updateCredentials() {
// System.out.println("Username= "+username+" password= "+password);
ModelAndView model = new ModelAndView();
model.addObject("title", "Credential Edit Operation");
model.addObject("message", "You are successfully updated your credentials");
model.addObject("edited", "TRUE");
model.setViewName("editpage");
System.out.println("executed updateCredentials POST method");
return model;
}
现在的问题是我在控制台中收到 405 错误,如下所示:
org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported
WARNING: Request method 'POST' not supported
谁能帮我解决这个错误?
【问题讨论】:
-
我在发布的代码中没有发现任何问题。还有其他事情出错了。很难说哪里可能是错的。要进一步调试,您的接听电话工作正常吗?如果是这样,当服务器启动时,它将吐出请求映射详细信息。检查映射是否绑定到控制器。
标签: spring-mvc httprequest httpresponse http-response-codes