Spring Boot中遇Request method DELETE not supported

  今天,我在Spring Boot中使用put和delete請求方式時,遇到Request method DELETE not supported的問題,很是頭疼,仔細檢查代碼沒發現什麼錯誤。直到用以下方式解決。

  我的Spring Boot版本是2.2.2,開始我沒有注意它和1.x的區別。

最新版本的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}"

轉載自:https://www.cnblogs.com/dgwblog/p/11976640.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章