对于一些直接跳转的页面我们可以不写controller

package com.gulimall.gulimallauth.config;

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 GulimallWebConfig implements WebMvcConfigurer {
    
    


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

重定向携带参数

RedirectAttributes redirectAttributes
redirectAttributes.addFlashAttribute(“errors”, errorMap);
重定向到新的页面这些参数取一次就没有了 原理是仿session

猜你喜欢

转载自blog.csdn.net/qq_36905956/article/details/112645110