Merge branch 'master' of github.com:elunez/eladmin

pull/189/head
dqjdda 2019-11-04 13:56:55 +08:00
commit 474e5688d9
2 changed files with 4 additions and 3 deletions

View File

@ -140,7 +140,8 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
try { try {
String fileName = name + nowStr + "." + suffix; String fileName = name + nowStr + "." + suffix;
String path = filePath + fileName; String path = filePath + fileName;
File dest = new File(path); // getCanonicalFile 可解析正确各种路径
File dest = new File(path).getCanonicalFile();
// 检测是否存在目录 // 检测是否存在目录
if (!dest.getParentFile().exists()) { if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs(); dest.getParentFile().mkdirs();

View File

@ -35,8 +35,8 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
String avatarUtl = "file:" + avatar.replace("\\","/"); String avatarUtl = Paths.get(avatar).normalize().toUri().toASCIIString();
String pathUtl = "file:" + path.replace("\\","/"); String pathUtl = Paths.get(path).normalize().toUri().toASCIIString();
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0); registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0); registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0); registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);