th:text属性与utext属性

本文介绍Thymeleaf中text与utext属性的区别及使用方法。text属性用于显示带有HTML标签的内容,而utext属性则用于显示纯文本内容,避免了HTML标签的解析。

1 th:text属性
可对表达式或变量求值,并将结果显示在其被包含的 html 标签体内替换原有html文本
文本连接:用“+”符号,若是变量表达式也可以用“|”符号
e.g.
若home.welcome=Welcome to our <b>fantastic</b> grocery store!<p th:text="#{home.welcome}"></p>解析结果为:

 

<p>Welcome to our <b>fantastic</b> grocery store!</p>

 


2 th:utext属性 解决方案 <p th:utext="#{home.welcome}"></p>即可。 Welcome to our fantastic grocery store! 等效于html :<p>Welcome to our <b>fantastic</b> grocery store!</p>
`<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Mask Status Report</title> <style> table { border-collapse: collapse; width: 100%; font-family: Arial, sans-serif; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; position: relative; } .td-content{ height: 100%; position: absolute; top: 0; padding: 0; width: 100%; left:0; display: flex; align-items: center; justify-content: center; } th { background-color: #f2f2f2; font-weight: bold; } .status-ok { background-color: #d4edda; } .status-onHold { background-color: #fff3cd; } .choice-yes { background-color: #66FF9957; } .choice-no { background-color: #FFCC9957; } .font-center{ text-align: center; } </style> </head> <body> <h2>Mask Status Report</h2> <table> <thead> <tr> <span th:text="${frameRecord.getValue()}"></span> </tr> <tr> <!-- 固定表头 --> <th>Mask ID</th> <th>Mask Code</th> <th>Layer Name</th> <th>JDV Status</th> <!-- 固定属性列 --> <th th:each="frameRecord : ${fixedFrameProps}"> <span th:text="${frameRecord.getValue()}"></span> </th> <!-- 动态用户列 --> <th th:each="userId : ${dynamicUserNames}"> <span th:text="${userId}"></span> </th> </tr> </thead> <tbody> <tr th:each="data : ${maskDataList}"> <!-- 固定数据 --> <td th:text="${data.maskId}"></td> <td th:text="${data.maskCode}"></td> <td th:text="${data.layerName}"></td> <td class="font-center" th:classappend="'status-' + ${data.getJdvStatus()}" th:text="${data.getJdvStatus()}"></td> <!-- 固定属性数据 --> <td th:each="prop : ${fixedFrameProps}"> <div class="td-content" th:each="frameRecord : ${data.jdvSignatureFormFrameRecordList}" th:if="${frameRecord.prop} == ${prop.key}" th:classappend="'choice-' + ${frameRecord.choice}"> <span th:text="${frameRecord.choice}"> </span> </div> </td> <!-- 动态用户数据 --> <td th:each="userId : ${dynamicUserNames}"> <div class="td-content" th:each="chipRecord : ${data.jdvSignatureFormChipRecordList}" th:if="${chipRecord.userId} == ${userId}" th:classappend="'choice-' + ${chipRecord.choice}"> <span th:text="${chipRecord.choice}"> </span> </div> </td> </tr> </tbody> </table> </body> </html> ` 现在我要在表格上面加一个正文,: {probody}-JDV review会签完成,rls mask/total mask:{rls},其中probody和rls是模板的变量怎么加
11-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值