在学习 SpringBoot 实现 RESTful 的删除操作时,需要将表单数据以 DELETE 方式提交,代码如下图所示:

SpringBoot DELETE请求时遇405报错问题(已解决)

在这里,我使用了JQuery的方式动态的将表单进行提交,下面是JQuery的代码,如下所示:

SpringBoot DELETE请求时遇405报错问题(已解决)

在实践过程中,点击 删除 按钮,跳转到 SpringBoot 默认的错误页面,如下图所示:

SpringBoot DELETE请求时遇405报错问题(已解决)
SpringBoot DELETE请求时遇405报错问题(已解决)

出现问题原因在于,springboot-autoconfigure包下的 additional-spring-configuration-metadata.json文件中 1441行处,默认情况下SpringBoot是关闭Spring的Hhiddenmethod过滤器的

SpringBoot DELETE请求时遇405报错问题(已解决)

解决方法:只需要在 application.properties配置文件中,添加 spring.mvc.hiddenmethod.filter.enabled = true 启动hiddenmethod过滤器即可解决

SpringBoot DELETE请求时遇405报错问题(已解决)

相关文章:

  • 2021-10-30
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2021-09-21
  • 2021-06-19
猜你喜欢
  • 2021-12-22
  • 2021-08-27
  • 1970-01-01
  • 2021-10-27
  • 2021-10-07
  • 2022-01-08
  • 2021-08-26
相关资源
相似解决方案