| | |
| | | package com.yuanchu.mom.config; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Configuration |
| | | public class OpenFifer extends WebMvcConfigurationSupport { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private FiferConfig fiferConfig; |
| | | |
| | | @Resource |
| | | private PowerConfig powerConfig; |
| | | |
| | | @Resource |
| | | private LogConfig logConfig; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | | |
| | | @Value("${outPath}") |
| | | private String outPath; |
| | | |
| | | |
| | | |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | //配置拦截器访问静态资源 |
| | | registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| | | |
| | | //设置文件虚拟路径映射 |
| | | registry.addResourceHandler("/img/**").addResourceLocations("file:"+filePath+"/"); |
| | | registry.addResourceHandler("/outPath/**").addResourceLocations("file:"+outPath); |
| | | } |
| | | |
| | | @Override |
| | | protected void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(fiferConfig).addPathPatterns("/**"); |
| | | registry.addInterceptor(powerConfig).addPathPatterns("/**"); |
| | | registry.addInterceptor(logConfig).addPathPatterns("/**"); |
| | | super.addInterceptors(registry); |
| | | } |
| | | } |