@Configuration @Import(value=SecurityConfiguration.class) public class SecurityAutoConfiguration extends Object implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
| 构造器和说明 |
|---|
SecurityAutoConfiguration() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
添加拦截器
注:这里之所以不将配置中anon()的路径添加到excludePathPatterns,是因为如下场景下发生异常难以定位:
GET /login anon()
ANY /** hasLogin()
然后访问/login报异常了,Spring Boot会重定向到/error,而此时并未配置/error的访问规则
于是命中到/**,于是报没有添加header的异常。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddArgumentResolvers, addCorsMappings, addFormatters, addResourceHandlers, addReturnValueHandlers, addViewControllers, configureAsyncSupport, configureContentNegotiation, configureDefaultServletHandling, configureHandlerExceptionResolvers, configureMessageConverters, configurePathMatch, configureViewResolvers, extendHandlerExceptionResolvers, extendMessageConverters, getMessageCodesResolver, getValidatorpublic void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
而不过滤,则会打印类似如下的日志: com.github.zj.dreamly.security.RestfulMatchUtil : match begins. GET /error, httpMethod = ANY, pattern = /login, methodMatch = true, pathMatches = false 问题定位会方便很多。
addInterceptors 在接口中 org.springframework.web.servlet.config.annotation.WebMvcConfigurerregistry - registryCopyright © 2019. All rights reserved.