Can Spring MVC have request parameters for an HTTP PUT method, or must I use post? Which should I use to be RESTful?

前端 未结 4 454
北海茫月
北海茫月 2020-12-25 15:02

I have a controller action I think should be an HTTP PUT, but Spring is complaining when I try and use @RequestParam in the controller action. Is request parameters not allo

4条回答
  •  无人及你
    2020-12-25 15:36

    Spring controllers support GET/HEAD/POST/PUT/DELETE/OPTIONS/TRACE, but since your browser may not be able to send these request methods, it wont work for you.

    The workaround is to use the "org.springframework.web.filter.HiddenHttpMethodFilter" provided by Spring. It requires you to pass a hidden parameter for the request method. The default parameter supported by this filter is "_method".

    Check the javadoc of the filter for more info.

提交回复
热议问题