我正在尝试将JSON与多部分请求结合起来,但是每次我得到Failed to parse multipart servlet request
这是我的配置:
<!-- Multipart configuration -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000000"/>
</bean>
这是我的控制器的方法:
@RequestMapping(value = "/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = {
MediaType.MULTIPART_FORM_DATA_VALUE })
public ResponseJson addExpenseNote(final HttpServletRequest httpServletRequest,
@RequestPart(name = "file", required = true) final MultipartFile file,
@RequestPart final Profile profile)
...
我正在使用Postman发送文件和带有content-type=multipart/mixed
的Json
如果我将content-type=
保留为空白,则会出现415错误。