Spring Boot Request method DELETE not supported

1: 开启HiddenHttpMethodFilter

最新版本的spring boot 默认不开启 restful 分割api

    @Bean
    @ConditionalOnMissingBean({HiddenHttpMethodFilter.class})
    @ConditionalOnProperty(
        prefix = "spring.mvc.hiddenmethod.filter",
        name = {"enabled"},
        matchIfMissing = false
    )

开启办法:

# 启用hiddenMethod过滤器
spring.mvc.hiddenmethod.filter.enabled=true

通过使用隐藏域参数来

th:attr="del_uri=@{/emp/}+${emp.id}"

当然也可以使用传统POST 来做处理 , 在from里面多做几个参数

推荐使用 Ajax ,直接支持delete请求 不过需要浏览器支持

猜你喜欢

转载自www.cnblogs.com/dgwblog/p/11976640.html