关于thymeleaf img src动态参数赋值
1、在pom.xml中配置thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2、配置application.properties路径
应该以什么样的路径来访问静态资源,这表示只有静态资源的访问路径为/static/ 时才会处理(如http://localhost:8080/static/css/base.css)
spring.mvc.static-path-pattern=/static/**
3、页面引用
<html lang="en" xmlns:th="http://www.thymeleaf.org">
取值和跳转
1、从数据库中取值
<img th:src="@{(${xxx.xxx})}">
2、从静态文件中取值
<img src="/static/images/1.gif" >
3、跳转controller路径带数据
<a th:href="@{/shop/delete(id=${shops.id})}"></a>
4、跳转controller路径不带数据
<a href="/shop/shopindex">网站首页</a>