[英]HTTP Status 405 - Request method 'GET' not supported when doing return “redirect:*.*” in spring mvc
In spring MVC... I have to reload a page after the record is updated. 在Spring MVC中...记录更新后,我必须重新加载页面。 So in the action method I am returning String and in return I am returning
所以在动作方法中,我返回的是String,而我返回的是
return "redirect:/recordList";
When but it is giving the exception on the page 何时但页面上出现异常
HTTP Status 405 - Request method 'GET' not supported
There is no exception coming on the logs. 日志上没有例外。
My controller method looks like 我的控制器方法看起来像
@RequestMapping(value= "/recordList", method = RequestMethod.POST)
public ModelAndView getAssetListForUser(@RequestParam("ldapId") String ldapId,
final HttpServletRequest request){
Also, because I need the value if ldapId in the controller method, I am binding it in the calling method like this 另外,因为我需要在controller方法中使用ldapId值,所以我将其绑定在这样的调用方法中
request.setAttribute("ldapId", assetAssetEmp.getAssetEmpId());
Please help. 请帮忙。
It looks like your /recordList
controller method only supports RequestMethod.POST
. 看来您的
/recordList
控制器方法仅支持RequestMethod.POST
。 hence you're getting the 405 GET Method not allowed error, since the redirect will issue a GET request. 由于重定向将发出GET请求,因此您将收到405 GET方法不允许错误。
to solve for it, try to give a GET version of your controller action. 要解决此问题,请尝试提供控制器操作的GET版本。 (the assetlist method) so that once the update happens, the asset list of the user can be returned via the GET method.
(资产列表方法),以便一旦发生更新,便可以通过GET方法返回用户的资产列表。
The @RequestMapping
annotation is your way to specify when your method is going to be called in an annotated controller. @RequestMapping
注释是您指定何时在带注释的控制器中调用您的方法的方法。 The RequestMethod.GET
and RequestMethod.POST
arguments allow you to respond to the specific HTTP
request type. RequestMethod.GET
和RequestMethod.POST
参数允许您响应特定的HTTP
请求类型。
providing method = RequestMethod.POST
to controller method actually making method to accept only HTTP POST
requests. 提供
method = RequestMethod.POST
到控制器方法,实际上使方法只接受HTTP POST
请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.