spring boot -thymeleaf的基本使用和常见问题

本文介绍了Thymeleaf模板引擎的基础知识,包括其在Spring Boot中的配置,以及th:text、$表达式、*表达式、@表达式、th:if和th:each等关键语法的使用。Thymeleaf允许在HTML中直接进行文本替换、属性设置和条件、迭代表达式,提供了一种简洁的模板设计方式。
摘要由CSDN通过智能技术生成

thymeleaf简介

thymeleaf是一个的java的模板引擎,能用来解析html,css.xml和纯文本。它是spring boot推荐使用的作为jsp的代替品,它比jsp更快,在没有被解析的情况下,仍然可以作为html文件展示。

spring boot thymeleaf 配置

引入相关依赖

    <parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.0.2.RELEASE</version>
    	</parent>
    	
    	<properties>
    	    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    	    <!-- set thymeleaf version -->
    	    <thymeleaf.version>3.0.10.RELEASE</thymeleaf.version>
    	    <thymeleaf-layout-dialect.version>2.0.0</thymeleaf-layout-dialect.version>
    	    <!--set java version-->
    	    <java.version>1.8</java.version>
    	  </properties>
    
    	<dependencies>
    
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    
    		<dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值