慕前端131612
Dave Syer的答案的示例:import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;@Configurationpublic class MyWebMvcConfig { @Bean public WebMvcConfigurerAdapter forwardToIndex() { return new WebMvcConfigurerAdapter() { @Override public void addViewControllers(ViewControllerRegistry registry) { // forward requests to /admin and /user to their index.html registry.addViewController("/admin").setViewName( "forward:/admin/index.html"); registry.addViewController("/user").setViewName( "forward:/user/index.html"); } }; }}