SpringBoot 使用 themeleaf
引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
yml配置文件
server:
port: 5001
spring:
application:
name: demoweb
thymeleaf:
encoding: utf-8
prefix: classpath:/html/
访问页面
@RequestMapping("/home")
public String index(){
return "index";
}
用themeleaf模板background-image: url()的图片链接如何写?
<div class="img w-100" th:style="'background-image: url('+@{/images/about.jpg}+');'"></div>