测试一个spring文件上传表单,controlelr签名长这样
@RequestMapping(value = "upload", method = RequestMethod.POST)
@ResponseBody
public void upload(@RequestParam("file") MultipartFile multipartFile) {}
和测试这个
final MockMultipartFile file
= new MockMultipartFile("content", "myFile.txt", "text/plain", "hello".getBytes());
MockHttpServletRequestBuilder mockHttpServletRequestBuilder =
.fileUpload("/upload/")
.file(file)
.accept(MediaType.APPLICATION_JSON);
但我得到上述:错误消息=所需的MultipartFile参数'文件'不存在