简体   繁体   English

HTTP状态405-在Spring MVC中执行返回“重定向:*。*”时,不支持请求方法“ GET”

[英]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.GETRequestMethod.POST参数允许您响应特定的HTTP请求类型。

providing method = RequestMethod.POST to controller method actually making method to accept only HTTP POST requests. 提供method = RequestMethod.POST到控制器方法,实际上使方法只接受HTTP POST请求。

RequestMethod 请求方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP状态405-Spring MVC不支持请求方法'POST' - HTTP Status 405 - Request method 'POST' not supported Spring MVC HTTP 状态 405 - 不支持请求方法“POST”(Spring MVC) - HTTP Status 405 - Request method 'POST' not supported (Spring MVC) Spring MVC - HTTP 状态 405 - 不支持请求方法“POST” - Spring MVC - HTTP Status 405 - Request method 'POST' not supported Spring MVC HTTP状态405-不支持请求方法“ POST” - Spring MVC HTTP Status 405 - Request method 'POST' not supported HTTP状态405 - 不支持请求方法“GET” - HTTP Status 405 - Request method 'GET' not supported Spring MVC:HTTP 405-发出POST请求时不支持请求方法“ GET” - Spring MVC: HTTP 405 - Request method 'GET' not supported when making POST request HTTP状态405 - 使用Spring Security的Spring MVC中不支持请求方法'POST' - HTTP Status 405 - Request method 'POST' not supported in Spring MVC with Spring Security 具有Spring Security的Spring-mvc获得HTTP状态405-请求方法'POST'不支持 - Spring-mvc with spring security getting HTTP Status 405 - Request method 'POST' not supported Spring MVC 上传文件 - HTTP 状态 405 - 不支持请求方法“POST” - Spring MVC upload file - HTTP Status 405 - Request method 'POST' not supported 405不允许使用方法http方法:使用Spring MVC时不支持请求方法'GET'。 - 405 Method Not Allowed http method being used: Request method 'GET' not supported` while using Spring MVC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM