是否可以将多部分表单的内容捆绑到相应控制器方法中的单个对象中?
即我如何转换方法
@RequestMapping(value = "/mult", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<SomeBean> upload(@RequestBody MultipartFile multipartFile, @RequestParam String param)
进入具有以下签名的方法:
@RequestMapping(value = "/mult", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<SomeBean> upload(@RequestBody MultipartWrapper wrapper)
其中MultipartWrapper
包含 multipartFile 和附加参数:
public class MultipartWrapper {
private String param;
private MultipartFile multipartFile;
// Getters & Setters
}