2HTTP Status 405 - Request method 'POST' not supported (Spring MVC) 3jsp spring mvc 上传时HTTP Status 405 - Request method 'GET' not supported是什么原因; 4置顶 Spring-boot、Spring-jdbc 、Spring-mvc; 5Java web高级编程——Spring MVC; 6Spring boot MVC: can't find JSP. Swagger-UI giving 405 (Method not. Request method 'GET' not supported at org. Turns out that this is an issue for both GET and POST endpoints i.e. 405 servlet HTTPステータス405は、Java Servletの非常に一般的なエラーメッセージです。 HTTP Status 405 - HTTP method GET is not supported by this URL type Status report message HTTP method GET is not supported by this URL description The specified HTTP method is not allowed for the requested resource (HTTP method GET is. Debugging I found there is no handler installed, but I still do not know why. The exception is thrown here: DispatcherSevlet.java protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception HttpServletRequest processedRequest = request; HandlerExecutionChain mappedHandler = null; boolean multipartRequestParsed = false; WebAsyncManager asyncManager. HTTP Status 405 - HTTP method POST is not supported by this URL type Status report message HTTP method POST is not supported by this URL description The specified HTTP method is not allowed for the requested resource.
2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2020阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
入口地址:https://www.aliyun.com/minisite/goods
推荐: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
|
this questionedited Jul 13 '14 at 6:11 asked Jul 13 '14 at 5:28 user3833530 30 1 1 4
405 Post Not Supported Device
| 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 | 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.
![405 405](/uploads/1/1/9/8/119846911/358272692.jpg)
|
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
405 Post Not Supported Spring 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.
|
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
@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.
|
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 MVC拦截405错误
Spring MVC框架对常见的全局异常都做了很好的处理,一般情况下我们无需关心和干预。默认情况下,如果出现如404、405等错误时,Spring会返回一个默认的ModelAndVi
- 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
Http 405 - Request Method 'post' Not Supported
最新文章
- 1在阿里架构师眼中构建一个较为通用的业务技术架构就是如此简单
- 2Java基础类String了解一下
- 3中国民航飞行学院人事薪资管理系统实践案例
- 4Java SE——线程介绍
- 5简单的方法构建一个高可用服务端
- 6CTO详细讲解海量日志处理ELK
2020腾讯云限时秒杀,爆款1核2G云服务器99元/年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2020阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
入口地址:https://www.aliyun.com/minisite/goods
推荐: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-boot| this question | edited May 25 at 20:02eis 26k 3 72 104 | asked Sep 9 '15 at 12:45 Adelin 4,868 13 55 98 |
Update the code of TagsController as well. – Rafal G. Sep 9 '15 at 13:55 | ||
| Consider rolling back to revision 2. Right now, the code in your question is correct, making the answer meaningless. – approxiblue Sep 10 '15 at 13:53 | |
@RafalG. the code in question is not supposed to be 'fixed', it breaks the question. – eis May 25 at 20:03 |
1 Answers
1
解决方法 | You have an error in RestController annotation definition. According to the docs it is:
Which means the value you have entered ('/backoffice/tags') is NAME of the controller not the path under which it is available. Add @RequestMapping('/backoffice/tags') on the controller's class and remove value from the @RestController annotation.EDIT: Fully working example as per comment that it does not work - try to use this code please - and run locally from IDE. build.gradle Tag.java SampleController.java DemoApplication.java
| |||
|
推荐:HTTP Status 405 -- HTTP method POST is not supported by this URLpackage web.filter; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServl
推荐:HTTP Status 405 -- HTTP method POST is not supported by this URL
package web.filter; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServl
- 1Java开发中的23种设计模式详解
- 2Spring mvc+hibernate+freemarker(开源项目)
Error 405 Request Method 'post' Not Supported Postman
- 1微信公众号文章采集,并发布到WordPress
- 2HTTP Status 405 - Request method 'POST' not supported (Spring MVC)
- 3HTTP Status 405 -- HTTP method POST is not supported by this URL
- 4HTTP Status 405 - HTTP method POST is not supported by this URL
- 5HTTP Status 405 - HTTP method GET(POST) is not supported by this URL
- 6jsp spring mvc 上传时HTTP Status 405 - Request method 'GET' not supported是什么原因
Spring Boot 405 Request Method 'post' Not Supported
最新文章
Spring Security 405 Post Not Supported
- 1在阿里架构师眼中构建一个较为通用的业务技术架构就是如此简单
- 2Java基础类String了解一下
- 3中国民航飞行学院人事薪资管理系统实践案例
- 4Java SE——线程介绍
- 5简单的方法构建一个高可用服务端
- 6CTO详细讲解海量日志处理ELK