1
我想在JSP頁面中AWS文件uplaod圖像鬥必需MultipartFile參數 '文件' 是不存在的Java Spring MVC的
我用這個代碼:
JSP文件標籤:
<input type="file" name="file" id="file" onchange="changePicture()">
控制器:
@RequestMapping(value = "/saveContact", method = RequestMethod.POST)
public @ResponseBody ModelAndView saveContact(@ModelAttribute Contacting Contacting,ModelAndView modelndView,HttpServletRequest request ,
@RequestParam("file") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
byte[] bytes = file.getBytes();}...(Is not all function)
的pom.xml:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
MvcConfigration.java:
@Bean(name = "multipartResolver")
public StandardServletMultipartResolver resolver() {
return new StandardServletMultipartResolver();
}
當我運行它,我得到這個錯誤:
Required MultipartFile parameter 'file' is not present
我能做些什麼,什麼不正確在我的代碼?