spring boot 定义启动页 到 login

当前办法只是针对 项目启动后 直接跳转到 指定静态页面  如果有验证身份 安全等问题 可以另外想办法 去添加 ,需要的直接  拉过去使用  修改 【"redirect:  需要启动后访问到文件位置得地址 ”】

直接上代码 :


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {
   /*
     * 配置默认跳转页面
     * */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        log.info("redirectToLogin is being called");
        registry.addViewController("/").setViewName("redirect:/page/login.html");
                                        
                                        //"redirect:/page/login.html”

    }

}

注意  : 这个是静态文件得 方法   是在 src/main/resources/static 下面的文件  

如果需要配置 src/main/resources/templates  目录 templates 下面得文件需要 另外的办法 !!! 

相关推荐

  1. spring boot 定义启动 login

    2024-04-24 16:54:04       18 阅读
  2. springboot启动加载数据库数据内存

    2024-04-24 16:54:04       44 阅读
  3. springboot启动后加载热点数据Redis

    2024-04-24 16:54:04       40 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-24 16:54:04       4 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-24 16:54:04       5 阅读
  3. 在Django里面运行非项目文件

    2024-04-24 16:54:04       4 阅读
  4. Python语言-面向对象

    2024-04-24 16:54:04       4 阅读

热门阅读

  1. Python技术:从入门到精通的指南

    2024-04-24 16:54:04       15 阅读
  2. 【QEMU系统分析之启动篇(十五)】

    2024-04-24 16:54:04       14 阅读
  3. 39、Lua 中调用C函数(lua-5.2.3)

    2024-04-24 16:54:04       17 阅读
  4. 基于Hadoop的石油大数据平台设计

    2024-04-24 16:54:04       19 阅读
  5. css中backface-visibility使用

    2024-04-24 16:54:04       18 阅读
  6. docker 故障解决

    2024-04-24 16:54:04       21 阅读
  7. bash test.sh 2>&1 &是什么意思?

    2024-04-24 16:54:04       47 阅读