springboot项目运行就打开浏览器跳指定页面的操作

本文介绍了如何在SpringBoot项目启动时自动打开浏览器并跳转到index页面。首先配置了Freemarker作为模板引擎,然后创建了首页跳转的Controller,最后在Spring Boot的启动类中添加了ApplicationReadyEvent监听器,确保应用初始化完成后准备接收请求。
摘要由CSDN通过智能技术生成

springboot项目运行就打开浏览器跳index页面

第一步:配置模板引擎(freemarker)
使用其他模板的可以自己配置,殊途同归。

spring:
  freemarker:
    enabled: true #是否启用freemarker
    template-loader-path: classpath:/templates/ #设定模板的加载路径,在resources/templates/文件
    suffix: .ftl #设定模板的后缀
    content-type: text/html
    check-template-location: true #是否检查模板位置是否存在
    cache: false #是否启用模板缓存
    charset: UTF-8 #模板编码
    allow-request-override: false #是否允许HttpServletRequest属性覆盖(隐藏)控制器生成的同名模型属性
    allow-session-override: false #是否允许HttpSession属性覆盖(隐藏)控制器生成的同名模型属性
    expose-request-attributes: false #设定所有request的属性在merge到模板的时候,是否要都添加到model中
    expose-session-attributes: false #是否在merge模板的时候,将HttpSession属性都添加到model中
    expose-spring-macro-helpers: true #设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用
    prefer-file-system-access: true #是否优先从文件系统加载template,以支持热加载,默认为true
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值