How to PUT multipart/form-data using Spring MockMvc?

前端 未结 3 2169
無奈伤痛
無奈伤痛 2021-01-17 07:33

I have a controller\'s method with a PUT method, which receives multipart/form-data:

   @RequestMapping(value = \"/putIn\", method = RequestMeth         


        
3条回答
  •  温柔的废话
    2021-01-17 07:56

    This is unfortunately currently not supported in Spring MVC Test, and I don't see a work-around other than creating your own custom MockPutMultipartHttpServletRequestBuilder and copying-n-pasting code from the standard implementation.

    For what it's worth, Spring MVC also does not support PUT requests for file uploads by default either. The Multipart resolvers are hard coded to accept only POST requests for file uploads -- both for Apache Commons and the standard Servlet API support.

    If you would like Spring to support PUT requests in addition, feel free to open a ticket in Spring's JIRA issue tracker.

提交回复
热议问题