Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
9882cb97
Commit
9882cb97
authored
Nov 04, 2019
by
j.yao.SUSE
Committed by
elunez
Nov 04, 2019
Browse files
静态资源路径映射优化 (#172)
优化后 获取静态资源路径和操作系统无关
parent
58575378
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java
View file @
9882cb97
...
...
@@ -35,8 +35,8 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
String
avatarUtl
=
"file:"
+
avatar
.
replace
(
"\\"
,
"/"
);
String
pathUtl
=
"file:"
+
path
.
replace
(
"\\"
,
"/"
);
String
avatarUtl
=
Paths
.
get
(
avatar
).
normalize
().
toUri
().
toASCIIString
(
);
String
pathUtl
=
Paths
.
get
(
path
).
normalize
().
toUri
().
toASCIIString
(
);
registry
.
addResourceHandler
(
"/avatar/**"
).
addResourceLocations
(
avatarUtl
).
setCachePeriod
(
0
);
registry
.
addResourceHandler
(
"/file/**"
).
addResourceLocations
(
pathUtl
).
setCachePeriod
(
0
);
registry
.
addResourceHandler
(
"/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
).
setCachePeriod
(
0
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment