Request Method Post Not Supported Spring Security
There is a variety of common attacks that Spring Security helps you to protect against. It starts with timing attacks (i.e. Spring Security will always hash the supplied password on login, even if the user does not exist) and ends up with protections against cache control attacks, content sniffing, click jacking, cross-site scripting and more. However, aligning with it means Spring Boot 1.x support won't work with Spring Boot 1.5.17.RELEASE or earlier. Based on #799 (comment), it doesn't seem to be an option although I'm personally leaning towards supporting the latest Spring Boot 1.5 release only with the latest versions of Micrometer to avoid any compatibility issues.
2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2020阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
I created a spring mvc application using freemarker template as view part. In this tried to add a model using forms.I am also using spring security Here is the code
When I generated my first entity with a one-to-many relationship, when running the app, I got the message 'Request method 'POST' not supported' everytime I want to save a new record. Here a paste some log messages: DEBUG org.springfram. By default, Spring AOP proxying is used to apply method security – if a secured method A is called by another method within the same class, security in A is ignored altogether. This means method A will execute without any security checking. 二 Request method 'POST' not supported 进入正文,跟前端进行数据联调时,别人联调都正常,到联调我的接口(进行数据获取)就出现了问题。 下面进行异常场景还原(后端环境:Spring MVC4.0.5): 1、前端访问我这边的接口抛出错误码: 405 Method not allowed 。.

employee.ftl
employeeController.java
web.xml
Spring-security.xml
When click submit button it returns error `
HTTP Status 405 - Request method 'POST' not supported
` I gave POST method on both ftl and controller. Then why would this happen?
javaspringspring-mvcspring-security|
this questionedited Dec 3 '14 at 10:55 asked Dec 3 '14 at 10:34 rohi 145 1 1 15 Which Spring version are you using? – Adriaan Koster Dec 3 '14 at 10:46 Can you show your web.xml? – Adriaan Koster Dec 3 '14 at 10:50 @AdriaanKoster i updated my question – rohi Dec 3 '14 at 10:55 |
4 Answers
4
---Accepted---Accepted---Accepted---I am not sure if this helps but I had the same problem.
You are using springSecurityFilterChain with CSRF protection. That means you have to send a token when you send a form via POST request. Try to add the next input to your form:
|
this answer answered Dec 3 '14 at 11:18 crm86 707 4 26 1 thanks it works for me – Amir Feb 5 '15 at 20:04 That fix one part of the probelm, but have you investigated why a missing CSRF Token results in a '405 Request method 'POST' not supported' instead of an 403? – Ralph Mar 3 at 12:23 |
As far as I saw, the mentioned solutions didn't work for latest SpringSecurity. Instead of passing through with hidden you can also send it through the action URL like below:
|

I found the solution. It is because of spring security Cross Site Request Forgery (CSRF) protection. It blocks the url. So i added an extra field inside the form.
Now it is working properly.
|
this answer answered Dec 3 '14 at 11:16 rohi 145 1 1 15 1 So you should accept prm's answer, right? – Adriaan Koster Dec 3 '14 at 12:49 @AdriaanKoster i haven't notice his answer. I found it before he post his answer. But Anyway now i ---Accepted---Accepted---Accepted--- his answer. – rohi Dec 4 '14 at 4:47 |
Try to replace:
Recommend:java - Spring MVC - HTTP Status 405 - Request method 'POST' not supported
have a simple upload form. The controller, i't a controller i've used a lot of times (never for a file upload though). @Controllerpublic class FileUploadController { @Autowired private HttpServletRequest request; @RequestMappi
with:
Unless you are using Spring 3.2
EDIT after seeing XML:
Try to move servlet-context.xml to your WEB-INF directory and rename it 'appServlet-context.xml'. Then remove the line:
From the contextConfigLocation in your web.xml.
The convention is that the context xml file is named '[servlet-name]-context.xml' where [servlet-name] is the name of the DispatcherServlet.
Also try to add a '/' to your form action, so:
|

Request Method Post Not Supported Spring Security Check
Recommend:java - HTTP Status 405 - Request method 'POST' not supported . Technology Used . Spring MVC and Spring security
to submit a page i am getting 'HTTP Status 405 - Request method 'POST' not supported .' Error. web.xml <xml version='1.0' encoding='UTF-8'><web-app xmlns='http://java.sun.com/xml/ns/javaee' xmlns:xsi='http://www.w3.org/2001/XMLSchem
Recommend:java - HTTP Status 405 - Request method 'POST' not supported . Technology Used . Spring MVC and Spring security
to submit a page i am getting 'HTTP Status 405 - Request method 'POST' not supported .' Error. web.xml <xml version='1.0' encoding='UTF-8'><web-app xmlns='http://java.sun.com/xml/ns/javaee' xmlns:xsi='http://www.w3.org/2001/XMLSchem
