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
全部评论

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务