绑定属性 th:attr="del_uri=@{/provider/}+${p.pid}" config //无后缀时访问登录页面,和后缀未登录拦截 @Configuration public class MySpringMvcConfigurer { @Bean public WebMvcConfigurer webMvcConfigurer() { return new WebMvcConfigurer(){ //添加视图控制 @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("main/public"); // registry.addViewController("/").setViewName("bill/list"); registry.addViewController("/index.html").setViewName("main/login"); //退出系统时 registry.addViewController("/main.html").setViewName("main/index"); //登录失败时 } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginHandlerInterceptor()) //指定要拦截的请求 /** 表示拦截所有请求 //.addPathPatterns("/**") .addPathPatterns("/a") //排除不需要拦截的请求路径 .excludePathPatterns("/", "/index.html", "/login") //springboot2+之后需要将静态资源文件的访问路径 也排除 .excludePathPatterns("/css/*", "/img/*","/js/*"); } }; } //区域解析器 @Bean public LocaleResolver localeResolver() { return new MyLocaleResolver(); } }
springboot第十一天
最新推荐文章于 2024-01-20 23:08:09 发布