th:text属性与utext属性


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>