将Bean添加到配置中以添加视图控制器。这是必须扩展的,
WebMvcConfigurerAdapter并且只需重写该
addViewControllers方法即可。
@Configurationpublic class AliasWebConfig extends WebMvcConfigurerAdapter { public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("forward:/manage/health"); registry.addViewController("/health").setViewName("forward:/manage/health"); }}或者,如果您要强制使用重定向
addRedirectViewController而不是
addViewController。
@Configurationpublic class AliasWebConfig extends WebMvcConfigurerAdapter { public void addViewControllers(ViewControllerRegistry registry) { registry. addRedirectViewController("/", "/manage/health"); registry.addRedirectViewController("/health","/manage/health"); }}


