- Request Method Get Not Supported
- Request Method Post Not Supported Spring Security Login
- Request Method 'post' Not Supported Spring Security 4
- Request Method Post Not Supported
- Request Method 'post' Not Supported J_spring_security_check
2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
Recommend:HTTP Status 405 - Request method 'POST' not supported Spring Security Java Config n trying to do login using spring security. Following is my code: pgLogin.jsp <%@ page language='java' contentType='text/html; charset=ISO-8859-1'.
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
- Spring Security + Hibernate XML Example. Java 15; Java 14; Java 13. Request method ‘POST’ not supported.
- Enable pre-post Annotations To use @PreAuthorize and @PostAuthorize annotations in our Spring Security application, we need to enable pre-post annotations. Find the code for XML configuration.Enable pre-post annotations using method-security namespace as given below.
employee.ftl
employeeController.java
web.xml
Spring-security.xml
Request Method Get Not Supported
When click submit button it returns error `
Request Method Post Not Supported Spring Security Login
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:
|
this answeredited Apr 29 '15 at 20:10 answered Apr 29 '15 at 19:05 Shahab A 41 4 |
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:
Request Method 'post' Not Supported Spring Security 4
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
this answeredited Dec 3 '14 at 11:09 answered Dec 3 '14 at 10:47 Adriaan Koster 10.6k 2 26 39 I am using spring version 3.2.3 – rohi Dec 3 '14 at 10:51 |
Request Method 'post' Not Supported J_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