<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
2.1.3版本
写个配置类解决
package edu.xiyou.config;
import edu.xiyou.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Created by mmm on 2019/4/1.
* TODO
* e-mail : 13032946420@163.com
* date : 2019/4/123:03
* desc :
* version: 1.0
*/
@Configuration
public class MyMvcConfigSecond implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/zxc/foo").setViewName("foo");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new MyInterceptor())
.addPathPatterns("/**").excludePathPatterns("/login", "/register","/","/layui/**","/X-admin/**");
}
}
themleaf访问