@Configuration public class MvcConfigurer extends WebMvcConfigurerAdapter { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/home").setViewName("home.html"); registry.setOrder(Ordered.HIGHEST_PRECEDENCE); } @Override public void configurePathMatch(PathMatchConfigurer configurer) { super.configurePathMatch(configurer); configurer.setUseSuffixPatternMatch(false);//当此参数设置为true的时候,那么/user.html,/user.aa,/user.*都能是正常访问的。 } }