配置文件
上传文件大小
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
上传文件路径
spring.http.multipart.location=C:/file/
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/public/, file:${spring.http.multipart.location}
String fileName = new Date().getTime() + file.getOriginalFilename();
System.out.println("fileName:" + file.getOriginalFilename());
// String path = session.getServletContext().getRealPath("/resource/") + fileName;
String path="C:\\file\\"+fileName;
File newFile = new File(path);
// 通过CommonsMultipartFile的方法直接写文件(注意这个时候)
file.transferTo(newFile);
return fileName;
下载功能
<a :href="'http://服务器地址:端口/'+路劲" style="text-decoration:none" download="" title="下载" mce_href="#">下载</a>