springboot webMvc常用配置

1. mvc 的适配器配置 WebMvcConfigurerAdapter

常用配置的选项如下:
springboot webMvc常用配置
示例:

a. addCorsMappings配置cors跨域限制等
b. addViewControllers配置view视图映射等
c. addResourceHanders配置资源路径等
d. addInterceptors配置拦截器等

springboot webMvc常用配置

拦截器的配置:
实现HandlerInterceptor接口
springboot webMvc常用配置

2.Filters过滤器的配置

继承OncePerRequestFilter重写doFilterInternal方法:
示例中:
AntPathMatcher 匹配忽略路径 ignoreMatcher 然后doSomething ….

配置:

springboot webMvc常用配置
注册:

springboot webMvc常用配置

如有疑问,可交流QQ:1461840384