专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

springboot和thymeleaf开发web应用

1、创建springboot项目,导入thymeleaf web开发包

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2、application.properties添加thymeleaf配置项

spring.thymeleaf.enabled=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true

示例源码:https://gitee.com/lion123/springboot-thymeleaf-demo

thymeleaf常用语法

在html页面中引入thymeleaf命名空间

变量表达式(获取变量值)

如果有数据,被替换完成前后端分离效果

字符截取长度

Login
th:unless 于 th:if 恰好相反,只有表达式中的条件不成立,才会显示其内容。

下拉选择

@{/usethymeleaf}是Context相关的相对路径,在渲染时会自动添加上当前Web应用的Context名字,假设context名字为seconddemo,
那么结果应该是/seconddemo/usethymeleaf,即URL中以”/“开头的路径(比如/usethymeleaf将会加上服务器地址和域名和应用cotextpath,形成完整的URL。
绝对路径
相对路径
Content路径,默认访问static下的css文件夹




未知

引入模块


© 2020 xxx


111

Name: zhangsan.

Age: 18.

friend: Rose.

日期格式化

js取值

css取值

文章永久链接:https://tech.souyunku.com/24978

未经允许不得转载:搜云库技术团队 » springboot和thymeleaf开发web应用

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们