Spring returns HTTP 405 for every HTTP POST which isn't authorized

前端 未结 1 1878
故里飘歌
故里飘歌 2021-01-22 14:35

It seems like Spring isn\'t routing/authorizing HTTP POST requests correctly. When I send a HTTP POST request I always get \"405 Method Not Allowed\" response and this in the lo

相关标签:
1条回答
  • 2021-01-22 14:41

    I had a similar problem. The problem was in controller, which handled error pages and supported only GET method. When I changed it to both GET and POST it started work.

    Example:

    @Controller
    public class ErrorController {
        @RequestMapping(value = "/error" method = {RequestMethod.GET, RequestMethod.POST})
        public String error(@RequestParam(value = "err", required = false) Integer paramErrorCode, Locale locale,
                ModelMap model, HttpServletRequest httpRequest) {
             // Do something   
         }
    

    See details https://stackoverflow.com/a/57571936/1839027

    0 讨论(0)
提交回复
热议问题