异常警告
No mapping for GET /bootstrap/css/bootstrap.min.css
等等
解决:
在自定义的拦截器内加入下列代码:
//防止.js .css等文件被拦截器拦截
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/" };
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
}
问题完美解决
值得注意的是,这部风代码运行过一次,即使删除了,下次静态资源都不会被拦截了!