注意请求参数: request Content-type:"multipart/form-data"
@RequestMapping(value = "upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void upload(HttpServletRequest request) throws Exception {
BaseResponseV2 responseV2 = new BaseResponseV2();
if( request instanceof MultipartHttpServletRequest == fa) {
return ;
}
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest)request;
MultipartFile multipartFile = multipartHttpServletRequest.getFile("doc-form-file");
System.out.println("formname:"+multipartFile.getName());
System.out.println("filename:"+multipartFile.getOriginalFilename());
multipartFile.transferTo(new File(System.getProperty("java.io.tmpdir")+File.separator+"text.xlsx"));
Map<String, String[]> paramMap = request.getParameterMap();
for(String key:paramMap.keySet()) {
for(String value:paramMap.get(key)) {
System.out.println(key+":"+value);
}
}