展开全部
具体搜索spring mvc 文件上传。
applicationContext.xml里配置
Controller里的方法:@RequestMapping(value = "/upload")
//多个文件的话声明为MultipartFile[] file
public ModelAndView upload(HttpServletRequest request,MultipartFile file){
String uploadPath=request.getSession().getServletContext().getRealPath("/");
String name=file.getOriginalFilename();
//你的代码
ModelAndView view=new ModelAndView();
return view;
}
页面里面form设置属性method="post" enctype="multipart/form-data"