Springboot使用put、delete请求报错
springboot给我们自动配置好了hiddenhttpmethodfilter,但是最近发现好像用不了,我用的是springboot版本是2.2.2,默认配置被改成了false,也就是关闭了自动配置,不知道sprongboot什么鬼,坑!!!
There was an unexpected error (type=Method Not Allowed, status=405).Request method ‘POST’ not supportedorg.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘POST’ not supported
要把springboot配置yml文件改成
spring: mvc: hiddenmethod: filter: enabled: true
登录后复制
Springboot错误提示405状态
一、错误提示405状态截图
二、405状态的原因
SpringBoot的自动配置中默认是关闭spring.mvc.hiddenmethod.filter 过滤器的,所以当我们提交的数据是PUT、POST、DELETE方式时,我们使用的 _method 并不起作用。
spring.mvc.hiddenmethod.filter 自动配置:
三、解决方法
在 Spring Boot 的配置文件 application.properties 中将 hiddenmethod.filter 过滤器设置为启用即可。
spring.mvc.hiddenmethod.filter.enabled=true
登录后复制
以上就是Springboot使用put、delete请求报错405怎么解决的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2627067.html