1、创建Config类,实现 WebMvcConfigurer 接口,重写 addViewControllers方法。
package whmf.archivesimage.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${system.loginV2}")
private Boolean loginV2 = false;
@Override
public void addViewControllers(ViewControllerRegistry registry) {
if(loginV2){
registry.addViewController("/").setViewName("forward:indexV2.html");
}else{
registry.addViewController("/").setViewName("forward:index.html");
}
}
}