@SpringBootConfiguration public class WebMvcConfiguration extends Object implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer
| Constructor and Description |
|---|
WebMvcConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
void |
addArgumentResolvers(List<org.springframework.web.method.support.HandlerMethodArgumentResolver> resolvers) |
void |
addCorsMappings(org.springframework.web.servlet.config.annotation.CorsRegistry registry)
重写父类提供的跨域请求处理的接口,目的是添加映射路径和具体的CORS配置信息
|
void |
addFormatters(org.springframework.format.FormatterRegistry registry)
添加类型转换器和格式化器
|
void |
addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
注册拦截器
|
void |
addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry)
配置自定义静态资源路径
|
void |
addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry)
addViewControllers可以方便的实现一个请求直接映射成视图,而无需书写controller
registry.addViewController("请求路径").setViewName("请求页面文件路径")
|
void |
configureHandlerExceptionResolvers(List<org.springframework.web.servlet.HandlerExceptionResolver> resolvers)
异常处理
|
void |
configureMessageConverters(List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
配置消息转换器--这里我用的是alibaba 开源的 fastjson
|
void |
configureViewResolvers(org.springframework.web.servlet.config.annotation.ViewResolverRegistry registry)
配置视图解析器
|
void |
extendHandlerExceptionResolvers(List<org.springframework.web.servlet.HandlerExceptionResolver> resolvers) |
public void addFormatters(org.springframework.format.FormatterRegistry registry)
addFormatters in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void configureHandlerExceptionResolvers(List<org.springframework.web.servlet.HandlerExceptionResolver> resolvers)
configureHandlerExceptionResolvers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void extendHandlerExceptionResolvers(List<org.springframework.web.servlet.HandlerExceptionResolver> resolvers)
extendHandlerExceptionResolvers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void addArgumentResolvers(List<org.springframework.web.method.support.HandlerMethodArgumentResolver> resolvers)
addArgumentResolvers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void configureViewResolvers(org.springframework.web.servlet.config.annotation.ViewResolverRegistry registry)
configureViewResolvers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void addViewControllers(org.springframework.web.servlet.config.annotation.ViewControllerRegistry registry)
addViewControllers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry)
1、addInterceptor 用于添加拦截规则 2、excludePathPatterns 用户排除拦截
addInterceptors in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry registry)
1、addResourceLocations指的是文件放置的目录 2、addResoureHandler指的是对外暴露的访问路径 3、SpringBoot 默认静态访问:classpath:/META-INF/resources/,classpath:/resources/,classpath:/static,classpath:/public/
addResourceHandlers in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void configureMessageConverters(List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
configureMessageConverters in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerpublic void addCorsMappings(org.springframework.web.servlet.config.annotation.CorsRegistry registry)
addCorsMappings in interface org.springframework.web.servlet.config.annotation.WebMvcConfigurerCopyright © 2019. All rights reserved.