package cn.edu.tju.config;
import cn.edu.yale.controller.MyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.method.HandlerTypePredicate;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.ResourceBundleViewResolver;
@Configuration
@ComponentScan("cn.edu.tju")
@EnableWebMvc
public class MyWebConfig implements WebMvcConfigurer {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer
//.setUseTrailingSlashMatch(false)
//.setUseRegisteredSuffixPatternMatch(true)
//.setPathMatcher(antPathMatcher())
//.setUrlPathHelper(urlPathHelper())
.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class));
}
}
上述配置后,会在原有路径上加上api这个前缀