Thymeleaf

引入依赖

<!--        引入thymeleaf-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>

引入名称空间

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

基本语法

1.表达式

${} :获取请求域、session域、对象等
*{} :获取上下文对象值
#{} :获取国际化等值
@{} :生成链接
~{} :相当于jsp:include作用:引入公共页面


字符串用: ''
空值:null
布尔运算:and , or  , ! , not

设置属性值- th:attr

  • 自动配好的策略
所有thyemleaf的配置都在 ThymeleafProperties
配置好了 SpringTemplateEngine
配好了 ThymeleafViewResolver
我们只需要开发页面

技巧

登录页面跳转到主页面,重定向防止表单重复提交
每个由controller跳转的页面都要加上Thymeleaf的名称空间
重定向之后seesion.setAttribu()会失效,得request.setAttribute
全部评论

相关推荐

01-14 19:01
吉首大学 Java
黑皮白袜臭脚体育生:加个项目吧,一般需要两个项目一业务一轮子呢,简历统一按使用了什么技术实现了什么功能解决了什么问题或提升了什么性能指标来写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务