我是参照这问大侠的帖子http://hbcui1984.javaeye.com/blog/51272在做到FileUploadController这个Java类的时候,里面个地方老是通不过:
protected ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object command,BindException errors){   
try {   
// cast the bean   
FileUploadBean bean = (FileUploadBean) command;   
  
// let's see if there's content there   
MultipartFile file = bean.getFile();   
                       
if (file == null) {   
throw new Exception("上传失败:文件为空");     
}   
if(file.getSize()>10000000)        
{   
throw new Exception("上传失败:文件大小不能超过10M");               
}   
//得到文件名   
String filename=file.getOriginalFilename();           
             
if(file.getSize()>0){                  
try {   
SaveFileFromInputStream(file.getInputStream(),"D:/",filename);   
} catch (IOException e) {   
System.out.println(e.getMessage());   
return null;   
}   
}else{   
throw new Exception("上传失败:上传文件不能为空");   
}   
// well, let's do nothing with the bean for now and return:   
try {   
return super.onSubmit(request, response, command, errors);   
} catch (Exception e) {   
System.out.println(e.getMessage());   
return null;   
}   
}catch(Exception ex){   
System.out.println(ex.getMessage());   
return null;   
}   
}就是这一句return super.onSubmit(request, response, command, errors); MyEclipse提示The method onSubmit(HttpServletRequest, HttpServletResponse, Object, BindException) is undefined for the type Object
我去org.springframework.web.servlet.mvc.SimpleFormController类里面看了下这个方法是有定义的,为什么MyEclipse会识别不出来?
想请教各位大侠,这样实现文件上传操作可行吗?还有没有更好的办法?