Spring Boot基础学习笔记09:Thymeleaf模板引擎
新建项目
添加项目依赖
设置文件名及保存路径
在全局配置文件里配置Thymeleaf属性
#缓存配置,默认即是true,开发阶段设置为false
spring.thymeleaf.cache = false
#设置模板使用的编码为utf-8
spring.thymeleaf.encoding = UTF-8
#指定为模板使用的模式为html5,默认html
spring.thymeleaf.mode = HTML5
#指定前缀,默认位置为/templates/,可以修改成其它位置
spring.thymeleaf.prefix = classpath:/templates/
#指定模板文件后缀,默认值为.html,可以修改成其它值
spring.thymeleaf.suffix = .html
创建登录控制器LoginController
在net.gzm.lesson09包里创建controller子包
在controller子包里创建LoginController控制器
用于前端模板页面动态数据替换效果的测试
创建模板文件,获取控制器传来的动态数据
在templates目录下创建模板文件login.html
静态访问模板文件,将显示默认值,而不会显示后台传来的动态数据
启动项目,访问http://localhost:8080/toLoginPage
启动项目
集成Bootstrap
1、引用在线文档