我正在使用此代码上传图片,但我总是得到 415 Unsupported Media Type
@RequestMapping(value = "/updateImage" , method = RequestMethod.POST)
public @ResponseBody ResponseMsg uploadFileHandler(
@RequestHeader(value="userid" ,required=false) String userid,
@RequestHeader(value="name" ,required=false) String name,
@RequestHeader(value="phone" ,required=false) Integer phone,
@RequestBody MultipartFile multipartFile,
HttpServletRequest request) throws IllegalStateException, IOException {
System.out.println("hi");
String orgName = multipartFile.getOriginalFilename();
orgName = CommonUtils.createUniqueFileName(orgName);
ServletContext sc = request.getSession().getServletContext();
String filePath = "uploadedImages/" + orgName;
String completePath = sc.getRealPath("/") + "/" + filePath;
File dest = new File(completePath);
multipartFile.transferTo(dest);
ResponseMsg responseMsg = CommonUtils.checkParam(userid, name, phone,filePath);
if (responseMsg.getStatus().equalsIgnoreCase("True"))
responseMsg = userService.updateProfile(userid, name, phone,filePath);
return responseMsg;
}