文件名称:SpringMVC文件上传下载
文件大小:9MB
文件格式:RAR
更新时间:2017-01-30 11:41:02
springMVC 文件上传 文件下载
SpringMVC文件上传下载
@Controller
@RequestMapping(value="/file")
public class FileController {
@Resource
private User user;
@RequestMapping(value="/toUpload")
public String toUpload(){
return "/upload";
}
@RequestMapping(value="/upload")
public String upload(@RequestParam("myfiles") MultipartFile myfiles) throws IOException{
System.out.println(user.getBeanName());
System.out.println(user.getBeanFactory());
if(!myfiles.isEmpty()){
String fileName=myfiles.getOriginalFilename();
System.out.println(fileName);
byte[] bytes = myfiles.getBytes();
FileCopyUtils.copy(bytes, new File("D:\\"+new Date().getTime()+fileName));
}
return "/success";
}
@RequestMapping(value="/download")
public ResponseEntity
【文件预览】:
upload
----WebContent()
--------META-INF()
--------WEB-INF()
----.settings()
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
--------org.eclipse.wst.common.project.facet.core.xml(345B)
--------org.eclipse.wst.common.component(472B)
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------.jsdtscope(503B)
--------org.eclipse.jdt.core.prefs(364B)
----src()
--------com()
--------applicationContext.xml(2KB)
----.project(1KB)
----.classpath(841B)
----build()
--------classes()