[英]Formatting a tag is not working with Thymeleaf
為什么這段代碼在文本之前顯示圖像:
<p>
<span>
<img src="../assets/images/favorite.svg" height="12px"/>
</span>
Baked Alaskan Salmon with Asparagus
</p>
但是當用Thymeleaf格式化時,它不會顯示圖像:
<p th:text="@{' ' + ${recipe.name}}">
<span>
<img src="../assets/images/favorite.svg" height="12px"/>
</span>
Baked Alaskan Salmon with Asparagus
</p>
嘗試使用Thymleaf's
th:inline="text"
標簽在Thymleaf
處理過的標簽內顯示html內容。 下面的代碼應該工作,雖然我沒有測試過
<p th:inline="text">
[[@{' ' + ${recipe.name}}]]
<span>
<img src="../assets/images/favorite.svg" style="height:12px"/>
</span>
Baked Alaskan Salmon with Asparagus
</p>
有關inline
代碼如何工作的更多說明,請查看文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.