问题描述:
在前端新增模板下载时,使用了新的下载请求路径,但在请求后,报认证失败,无法访问系统资源, code :401
问题原因:
- 若依框架带有的拦截器,拦截了请求。
解决步骤:
在后端的SecurityConfig.java 文件中的protected void configure(HttpSecurity httpSecurity)
方法,内添加请求路径,放过下载请求。
// 下载路径 允许匿名访问
.antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous()
.anonymous() | 使用 anonymous() 所有人都能访问,但是带上 token 访问后会报错 |
.permitAll() | 使用 permitAll() 方法所有人都能访问,包括带上 token 访问 |