springboot项目中以 PUT 方法提交表单数据,@DeleteMapping请求时出错,页面显示Request method ‘POST’ not supported
原因是 Spring 的 hiddenmethod 过滤器默认是关闭的,在表单提交的数据中 "_method" 数据并不起作用。解决方法:
application.properties中将 hiddenmethod 过滤器设置为启用即可
#启用hiddenMethod过滤器
spring.mvc.hiddenmethod.filter.enabled = true
SpringBoot PUT请求与hiddenMethod过滤器配置
当在SpringBoot项目中使用PUT方法提交表单时遇到@DeleteMapping请求错误,问题根源在于hiddenMethod过滤器默认未启用。解决方法是在application.properties文件中开启该过滤器,通过设置`spring.mvc.hiddenmethod.filter.enabled=true`,使_form表单中的 '_method' 数据生效,从而正确处理HTTP请求方法。
3545

被折叠的 条评论
为什么被折叠?



