Open houyouliang opened 7 years ago
package com.hat.service.configuration;
import org.springframework.context.annotation.Bean; 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.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.hat.service.interceptor.AuthInterceptor; import com.hat.service.interceptor.AuthPageInterceptor; import com.hat.service.interceptor.VisitInterceptor;
@Configuration public class InterceptorConfig extends WebMvcConfigurerAdapter{
@Bean public VisitInterceptor getVisitInterceptor() { return new VisitInterceptor(); } @Bean public AuthInterceptor getAuthInterceptor() { return new AuthInterceptor(); } @Override public void addInterceptors(InterceptorRegistry registry) { // TODO Auto-generated method stub // 使用channelNo+Ip 生成token // 时验证token是否被修改 //registry.addInterceptor(getVisitInterceptor()).addPathPatterns("/security/**"); // 后台数据权限管理接口 //registry.addInterceptor(getAuthInterceptor()).addPathPatterns("/auth/**"); registry.addInterceptor(getAuthPageInterceptor()).addPathPatterns("/statistics/**"); super.addInterceptors(registry); } @Bean public AuthPageInterceptor getAuthPageInterceptor() { return new AuthPageInterceptor(); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/fonts/**").addResourceLocations("/fonts/"); super.addResourceHandlers(registry); } @Override public void addViewControllers(ViewControllerRegistry registry) { //registry.addViewController("/").setViewName("forward:/login.html"); registry.addViewController("/").setViewName("redirect:/login.html"); super.addViewControllers(registry); }
}
package com.hat.service.configuration;
import org.springframework.context.annotation.Bean; 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.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.hat.service.interceptor.AuthInterceptor; import com.hat.service.interceptor.AuthPageInterceptor; import com.hat.service.interceptor.VisitInterceptor;
@Configuration public class InterceptorConfig extends WebMvcConfigurerAdapter{
}