123456789101112131415161718192021222324252627282930313233 |
- package com.lovecoding.mvc.config;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.core.convert.converter.Converter;
- import org.springframework.format.FormatterRegistry;
- import org.springframework.web.servlet.config.annotation.EnableWebMvc;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
- @Configuration
- @ComponentScan("com.lovecoding.mvc")
- @EnableWebMvc
- public class SpringMvcConfig implements WebMvcConfigurer {
- public void addFormatters(FormatterRegistry registry) {
- registry.addConverter(new DateConverter());
- }
- // public void addInterceptors(InterceptorRegistry registry) {
- //
- // //如此配置 全局可用 当前框架所有MVC请求都被 拦截器过滤了
- // //registry.addInterceptor( new MyInterceptor() );
- //
- // //拦截指定URL 请求, 并排除其他URL路径
- // registry.addInterceptor( new MyInterceptor() )
- // .addPathPatterns("/mybatis")
- // .excludePathPatterns("/login");
- //
- // }
- }
|