後台:
@RequestMapping(method = RequestMethod.POST,params="picture")
public @ResponseBody String updateLoad(@RequestParam(value = "file") MultipartFile file) {
String filePath = request.getSession().getServletContext().getRealPath("/") + java.io.File.separator + AppConstants.PICTURE_PLACE;
String name = FileUtil.saveFile(file, filePath);
return name;
}
前台:
<form id="imageUploadForm" action='coupon?picture' method="post" enctype='multipart/form-data'>
<input type="file" name="file" class="default" />
<input type="submit" value="upload" />
</form>
報錯:Required MultipartFile parameter 'file' is not present,怎麼改能不報錯,並且傳過來的file 不為null