江湖救急, springboot 配置拦截器静态资源的配置老是不生效,弄了一天了,哎!

2019-04-17 10:04:02 +08:00
 fangch

springboot 的版本是
2.1.4

application.yml 中的配置是:
spring:mvc:static-path-pattern:/static/**

mvc 的配置是:
@Configuration
public class MvcConfig implements WebMvcConfigurer {

@Autowired
private SessionInterceptor sessionInterceptor;

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
}

@Override
public void addInterceptors(InterceptorRegistry registry){

    registry.addInterceptor(sessionInterceptor)
            .addPathPatterns("/**")
            .excludePathPatterns("/static/**","/login","/js/**");

}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/static/**");
}

}

前台访问的的静态资源的链接是;
http://localhost:8081/js/jquery-3.3.1.min.js ,这个是已经配置了排除了,但是为什么还是被拦截!

说明:
配置中 /login 这个请求已经拦截已经生效了,但是为什么静态资源没有生效,希望大佬帮忙看看有哪些地方错了!

5360 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/555912

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX