Loading

SpringBoot配置 访问路径到视图的映射

增加此配置后,就不需要在controller中手动写路径到视图的映射了

/**
 * @author houChen
 * @date 2021/12/18 15:51
 * @Description:
 *
 * 访问路径和视图的映射
 * 添加了此配置类,就不需要写controller到视图的跳转
 *
 */
@Configuration
public class GulimallWebConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("index.html").setViewName("index");
        registry.addViewController("reg.html").setViewName("reg");
    }
}

image

posted @ 2021-12-19 15:46  青岑  阅读(245)  评论(0编辑  收藏  举报