目录
- Springboot使用put、delete请求报错
- Springboot错误提示405状态
- 一、错误提示405状态截图
- 二、405状态的原因
- 三、解决方法
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 supported
org.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
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)