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
MCMS
Commits
1a1dd38d
Commit
1a1dd38d
authored
Sep 25, 2019
by
sgjj
Browse files
自定义路径上传
parent
9e733b32
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/config/WebConfig.java
View file @
1a1dd38d
...
@@ -32,6 +32,16 @@ import net.mingsoft.basic.util.BasicUtil;
...
@@ -32,6 +32,16 @@ import net.mingsoft.basic.util.BasicUtil;
@Configuration
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
public
class
WebConfig
implements
WebMvcConfigurer
{
/**
* 上传路径
*/
@Value
(
"${ms.upload.path}"
)
private
String
uploadFloderPath
;
/**
* 上传路径映射
*/
@Value
(
"${ms.upload.mapping}"
)
private
String
uploadMapping
;
@Bean
@Bean
public
ActionInterceptor
actionInterceptor
()
{
public
ActionInterceptor
actionInterceptor
()
{
return
new
ActionInterceptor
();
return
new
ActionInterceptor
();
...
@@ -62,7 +72,13 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -62,7 +72,13 @@ public class WebConfig implements WebMvcConfigurer {
registry
.
addResourceHandler
(
"/app/**"
).
addResourceLocations
(
"/app/"
,
"file:app/"
,
"classpath:/app/"
);
registry
.
addResourceHandler
(
"/app/**"
).
addResourceLocations
(
"/app/"
,
"file:app/"
,
"classpath:/app/"
);
registry
.
addResourceHandler
(
"/static/**"
,
"/**"
).
addResourceLocations
(
"/static/"
,
"file:static/"
,
"classpath:/static/"
);
registry
.
addResourceHandler
(
"/static/**"
,
"/**"
).
addResourceLocations
(
"/static/"
,
"file:static/"
,
"classpath:/static/"
);
registry
.
addResourceHandler
(
"/api/**"
).
addResourceLocations
(
"/api/"
,
"file:api/"
,
"classpath:/api/"
);
registry
.
addResourceHandler
(
"/api/**"
).
addResourceLocations
(
"/api/"
,
"file:api/"
,
"classpath:/api/"
);
if
(
uploadFloderPath
.
startsWith
(
"file:"
)){
//如果指定了绝对路径,上传的文件都映射到uploadMapping下
registry
.
addResourceHandler
(
uploadMapping
).
addResourceLocations
(
uploadFloderPath
+
File
.
separator
//映射其他路径文件
//,file:F://images
);
}
}
}
/**
/**
* druidServlet注册
* druidServlet注册
...
...
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