springmvc二十八:springmvc使用common-fileUpload实现文件上传

springmvcjar包  commons-fileupload-1.2.1,commons-io-1.3.2

 

前台: 

	

使用spring mvc提供的类的方法上传文件

 

 配置:


		
			
			
		

 

后台:

@RequestMapping("/hello")
	public String hello(@RequestParam("file") CommonsMultipartFile file) throws IllegalStateException, IOException{
		
		System.out.println(file.getName());
		System.out.println(file.getOriginalFilename());
		
		file.transferTo(new File("D:\\"+file.getOriginalFilename()));
		return "hello";
	}

 

你可能感兴趣的:(Spring,MVC)