|
|
|
|
@ -53,18 +53,23 @@ public class WebConfig implements WebMvcConfigurer { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
|
|
|
|
|
|
|
|
|
registry.addResourceHandler("/upload/**").addResourceLocations("file:" + BasicUtil.getRealPath("upload") + File.separator); |
|
|
|
|
registry.addResourceHandler("/html/**").addResourceLocations("file:" + BasicUtil.getRealPath("html") + File.separator); |
|
|
|
|
registry.addResourceHandler("/templets/**").addResourceLocations("file:" + BasicUtil.getRealPath("templets") + File.separator); |
|
|
|
|
registry.addResourceHandler("/app/**").addResourceLocations("file:" + BasicUtil.getRealPath("app") + File.separator, "classpath:/app/"); |
|
|
|
|
registry.addResourceHandler("/static/**").addResourceLocations("file:" + BasicUtil.getRealPath("static") + File.separator, "classpath:/static/"); |
|
|
|
|
registry.addResourceHandler("/api/**").addResourceLocations("file:" + BasicUtil.getRealPath("api") + File.separator, "classpath:/api/"); |
|
|
|
|
//jar包方式映射处理
|
|
|
|
|
String classPath = BasicUtil.getClassPath(""); |
|
|
|
|
if (classPath.startsWith("file")) { |
|
|
|
|
registry.addResourceHandler("/upload/**").addResourceLocations("file:" + BasicUtil.getRealPath("upload") + File.separator); |
|
|
|
|
registry.addResourceHandler("/html/**").addResourceLocations("file:" + BasicUtil.getRealPath("html") + File.separator); |
|
|
|
|
registry.addResourceHandler("/templets/**").addResourceLocations("file:" + BasicUtil.getRealPath("templets") + File.separator); |
|
|
|
|
} else { |
|
|
|
|
//必须做判断,不然jar运行的html路径会被覆盖掉
|
|
|
|
|
registry.addResourceHandler("/html/**").addResourceLocations("/html/"); |
|
|
|
|
} |
|
|
|
|
registry.addResourceHandler("/app/**").addResourceLocations("/app/", "classpath:/app/"); |
|
|
|
|
registry.addResourceHandler("/static/**").addResourceLocations("/static/", "classpath:/static/"); |
|
|
|
|
registry.addResourceHandler("/api/**").addResourceLocations("/api/", "classpath:/api/"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* druidServlet注册 |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* druidServlet注册 |
|
|
|
|
*/ |
|
|
|
|
@Bean |
|
|
|
|
public ServletRegistrationBean druidServletRegistration() { |
|
|
|
|
ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet()); |
|
|
|
|
|