使用springboot2.0+的版本建立拦截器拦截访问时,发现将静态的css/js资源也拦截了。此时需要在拦截器中配置放行资源。直接上代码

 //设置拦截,释放静态文件
       registry.addInterceptor(new LoginHandlerInterceptero()).addPathPatterns("/**")
               .excludePathPatterns("/user/login","/login.html","/css/**","/js/**");

放行"/css/**"资源。
有些使用放行static文件夹来放行所有的静态资源,不过SpringBoot默认扫描static包下的静态资源,所以好像不管用。

下图是一次项目中配置的静态资源释放,SpringBoot拦截器拦截静态资源问题对文件结构不是很清楚,所以直接配置释放所有文件。

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-09-10
  • 2021-09-12
  • 2022-01-12
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-05-19
  • 2021-10-24
  • 2021-10-10
相关资源
相似解决方案