thymeleaf @{}和${}的结合使用
使用thymeleaf开发时,拼接支持rest风格的uri
在写图片路径时,在@{}中直接写${},能够解析成功,如下:
<img src="" alt="" th:src="@{${prod.prodImage}}">
但是在a标签的href中这样写,解析失败,如下:
<a th:href="@{/product/${prod.prodId}}"></a>
后经查阅使用下面这种成功,如下:
<a th:href="@{/product/{prodId}(prodId=${prod.prodId})}"></a>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f94819ddb85832c98d0b9ad6ff29a7f7.png)