SpringBoot中 發送PUT DDELETE(Restful)請求

寫一個過濾器

@Configuration
public class HttpRequestConfig {

    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
        HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();
        hiddenHttpMethodFilter.setBeanName("HiddenHttpMethodFilter");
        hiddenHttpMethodFilter.setMethodParam("_method");
        return hiddenHttpMethodFilter;
    }
}

然後在form中寫一個hidden類型的input

<input type="hidden" name="_method" value="put">

接收請求

@PutMapping("/XXX") == @RequestMapping(value = "/XXX", method = RequestMethod.PUT)

 

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