perf:globalConfig重定向调整

This commit is contained in:
曾文豪
2023-01-10 15:02:02 +08:00
parent 22bd0b05df
commit 933cb30443

View File

@@ -1,5 +1,6 @@
package com.tiesheng.util.config; package com.tiesheng.util.config;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
@@ -66,10 +67,12 @@ public class GlobalConfig {
if (resources.length == 0) { if (resources.length == 0) {
throw new ApiException("无法重定向,请检查资源"); throw new ApiException("无法重定向,请检查资源");
} }
String filename = resources[resources.length - 1].getFile().getPath(); String filename = resources[resources.length - 1].getURL().getPath();
filename = FileUtil.normalize(filename);
String path = buildPath(String.format("/%s%s#%s", htmlDir, StrUtil.subAfter(filename, htmlDir, true), route)); String path = buildPath(String.format("/%s%s#%s", htmlDir, StrUtil.subAfter(filename, htmlDir, true), route));
response.sendRedirect(path); response.sendRedirect(path);
} catch (IOException ignored) { } catch (IOException e) {
LogFactory.get().info(e);
} }
} }