1234567891011121314151617181920212223242526272829303132333435363738 |
- package cn.minbb.job.config;
- import cn.minbb.job.interceptor.AppInterceptor;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.web.method.support.HandlerMethodArgumentResolver;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
- import java.util.List;
- @Configuration
- public class WebMvcConfig implements WebMvcConfigurer {
- private final AppInterceptor appInterceptor;
- public WebMvcConfig(AppInterceptor appInterceptor) {
- this.appInterceptor = appInterceptor;
- }
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- // 多个拦截器组成一个拦截器链
- registry.addInterceptor(appInterceptor);
- }
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- // 和页面有关的静态目录都放在项目的 static 目录下
- registry.addResourceHandler("/**")
- .addResourceLocations("classpath:/static/", "classpath:/META-INF/resources/")
- .setCachePeriod(0);
- }
- @Override
- public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
- }
- }
|