405 Post Not Supported

2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062

Ideacentre k430. 2020阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods Cricket coach 2014 license key.

URL 복사 이웃추가 HTTP Status 405 - Request method 'POST' not supported Form에서 보내는 형식과 컨트롤러에서 받는 형식이 달라서 나는 오류로 jsp파일에서 form의 method는 post로 해놓고, ajax통신에서는 get으로 해놓음. 405 Method Not Allowed The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting. Please contact the server's administrator if this problem persists. HTTP Status 405 - Request method 'POST' not supported. Type Status report. Message Request method 'POST' not supported.

  1. HTTP Status 405 - HTTP method POST is not supported by this URL Status report HTTP method POST is not supported by this URL The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL). Solution: Simple answer: your servlet needs to implement doPost(HttpServletRequest, HttpServletResponse.
  2. The request failed with HTTP Status 405: Method Not Allowed This behavior occurs when you use the EditSite tool to create additional virtual directories in Project Server 2003. In this case, the.wsdl file may not be mapped correctly in Microsoft Internet Information Services (IIS).

推荐:HTTP Status 405 - Request method 'POST' not supported (Spring MVC)

HTTP Status 405 - Request method 'POST' not supported (Spring MVC) <html> <head> <meta http-equiv='Content-Type'nofollow'>javaspringspring-mvcspring-boot
|
this questionedited Jul 13 '14 at 6:11 asked Jul 13 '14 at 5:28 user3833530 30 1 1 4

|

6 Answers
6

解决方法

Have a look at the logs (with security at DEBUG) and you will discover the problem. Most likely you haven't disabled csrf protection and you client isn't sending the csrf token. (Standard Spring Security, not Spring Boot, although if you are using the Boot security autoconfig you can switch off csrf with an external config setting.)


|
this answer answered Jul 13 '14 at 6:25 Dave Syer 31.1k 5 82 91 The config setting for Spring Boot: security.enable-csrf=false – naXa Feb 28 '16 at 23:25 | Error 405 post method not supported

I had same error because of csrf protection. If csrf protection is enabled you need to send csrf parameters in request header.

You can also check Spring documentation here.

I added this parameters into my jsp file

And modified my ajax call like below.


Post405 Post Not Supported |
this answeredited Apr 18 '15 at 8:01Timeless 1,907 5 29 56 answered Nov 17 '14 at 0:03 fyelci 452 7 15 O'Man! you saved my day! this really works. +1 for great effort. – Arshad Ali May 10 '16 at 12:42 |

First of all, in Spring 4 you can use @RestController annotation on your rest controller class, which allows you to remove @RequestBody annotations from your methods. Makes it cleaner.

For second, would you maybe show more of your angular code? I think you should consider using factory services to make requests to backend. For example, have a service (this service already provides post, get, delete by default):

Now in your Angular controller you make a new User object that you use to call this service methods.

推荐:Spring Boot 之 MVC

上一次我们使用Spring Boot开发了一个简单的REST服务应用,那么传统网页应用怎么做呢? 渲染HTML是Spring Boot可以完美胜任的,并且提供了多种模板引擎的默认配

Query all (GET): User.query();

Query one (GET): User.get({id: userId});

Insert (POST): User.$save();

Update (PUT): User.$update();

Remove (DELETE): User.delete({id: userId}

I've written my Angular apps like that also using Spring boot and works well.


|
this answeredited Jul 13 '14 at 11:34 answered Jul 13 '14 at 11:25 Vaelyr 1,148 1 4 15 I use jspViewResolver to direct to specific jsp pages. Once I change my to @RestController it no longer works do I have to create another Class that uses @Controller to direct to specific jsp pages? – Eric Huang Dec 12 '16 at 4:31 You cannot use both of them together. You either 1) return JSON and use it in front-end 2) put your data into model map and return view. – Vaelyr Dec 12 '16 at 10:56 |

I had the same problem and resolved it by using the @RestController annotation instead of the 'plain' @Controller annotation on my controller.


405 Post Not Supported |
this answer answered Apr 21 '15 at 20:27 user3574606 11 1 This is the only solution that worked for me. Does anyone have any idea why? I was using Spring Boot with security starter and wanted to upload a multipart to Post@Controller. After changing it to @RestController it started working for some reason. I do not like not knowing why.. Any ideas? – Cleankod Nov 24 '15 at 19:38 What is more interesting, the exception was thrown after the request has been successfully processed inside the controller method (at the exiting of the method). – Cleankod Nov 24 '15 at 19:45 |

Your problem is that the endpoints for findById and updateUser are the same which is api/users/{id} and since the one with GET method comes first it will be evaluated first when you send a PUT request and hence will be rejected by spring.

I suggest you change the endpoint for updating user to api/users/update/{id} as below:


|
this answeredited Dec 12 '16 at 11:21 answered Dec 12 '16 at 11:15 Sohlowmawn 296 1 9 |

Your code on Spring MVC looks good to me, so I suspect the syntax on AngularJS being correct. I am not familiar with AngularJS, but I found an online tutorial regarding the $http function

from this link, http://tutorials.jenkov.com/angularjs/ajax.html

Hope it will help.

Error 405 Post Method Not Supported


|
this answer answered Jul 13 '14 at 5:52 Dino Tw 1,230 1 15 29 thanks for the response, I'm much more familiar with the angular side than the spring side. The $http request is valid and produces the expected result (an HTTP PUT request to localhost/api/users/1). I've also manually hit this endpoint using the chrome extension Postman. I'm not terribly familiar with spring boots auto configuration and am thinking that maybe there is some kind of manual configuration that needs to happen to enable PUT and POST requests, but then again I don't really know if that is the case. – user3833530 Jul 13 '14 at 6:08 |

推荐:Spring MVC拦截405错误

Spring MVC框架对常见的全局异常都做了很好的处理,一般情况下我们无需关心和干预。默认情况下,如果出现如404、405等错误时,Spring会返回一个默认的ModelAndVi

Spring 405 Post Not Supported

  • 1Spring mvc+hibernate+freemarker(开源项目)
  • 2Spring mvc+hibernate+freemarker(开源项目) - java,oracle,mysql,jquery,linux,Struts,Spring,Hibernate,maven webservices,Nosql,hudoop,git,osgi,easymock,nginx,jbpm,jni,jpa等资料下载地址 http://pa
  • 1微信公众号文章采集,并发布到WordPress
  • 2HTTP Status 405 - Request method 'POST' not supported (Spring MVC)
  • 3Spring MVC拦截405错误
  • 4Spring Boot 之 MVC
  • 5jsp spring mvc 上传时HTTP Status 405 - Request method 'GET' not supported是什么原因
  • 6Customizing HttpMessageConverters with Spring Boot and Spring MVC

最新文章

  • 1在阿里架构师眼中构建一个较为通用的业务技术架构就是如此简单
  • 2Java基础类String了解一下
  • 3中国民航飞行学院人事薪资管理系统实践案例
  • 4Java SE——线程介绍
  • 5简单的方法构建一个高可用服务端
  • 6CTO详细讲解海量日志处理ELK

405 Method Not Allowed should be returned by a server when a certainHTTP method is not supported at a resource.

It’s a bit different from 403 Forbidden. 403 suggest that the servermight support the HTTP request, but the client doesn’t have the rightprivileges to do the HTTP request.

405 Method Not Allowed means that the HTTP method is simply not supported.For example, a client might do a POST request on a resource where POSTis not implemented or it’s meaningless.

Spring Boot 405 Request Method 'post' Not Supported

A server generating the 405 response must also tell the client which HTTPmethods it can do, using the Allow header.

Example

Well, the next couple of weeks are going to be pretty quiet on the web, so I’mtaking a short break of these series and see you back January 8th!

References

405 Post Not Supported Device

  • RFC7231, Section 6.5.5 - 405 Method Not Allowed