| | |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.alibaba.fastjson.support.config.FastJsonConfig; |
| | | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; |
| | | import com.lf.server.interceptor.AuthInterceptor; |
| | | import com.lf.server.service.all.SysService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.AntPathMatcher; |
| | | import org.springframework.web.servlet.config.annotation.*; |
| | | |
| | |
| | | * Web配置类 |
| | | * @author WWW |
| | | */ |
| | | @Component |
| | | @Configuration |
| | | public class WebConfig extends WebMvcConfigurationSupport { |
| | | @Autowired |
| | | private SysService sysService; |
| | | |
| | | @Override |
| | | public void addViewControllers(ViewControllerRegistry registry) { |
| | | // 设置访问路径为 “/” 跳转到指定页面 |
| | | registry.addViewController("/").setViewName("redirect:/sign/toIndex"); |
| | | // 设置为最高优先级 |
| | | registry.setOrder(Ordered.HIGHEST_PRECEDENCE); |
| | | } |
| | | |
| | | /** |
| | | * 获取拦截器对象 |
| | | * |
| | | * @return |
| | | */ |
| | | public AuthInterceptor getAuthBean() { |
| | | return new AuthInterceptor(sysService); |
| | | } |
| | | |
| | | /** |
| | | * swagger控制 |
| | | */ |
| | | @Override |
| | | protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); |
| | | registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); |
| | | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); |
| | | super.addResourceHandlers(registry); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | protected void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(getAuthBean()) |
| | | // .excludePathPatterns("/swagger", "/webjars/**", "/v2/**", "/sign/**") |
| | | .addPathPatterns("/**"); |
| | | super.addInterceptors(registry); |
| | | } |
| | | |