96下午 springboot-2cp 利用Thymeleaf 发送值到页面 (未完善)
作者:互联网
Thymeleaf 的四种表达式
1.变量表达式(ognl表达式) 或者是Spring 的EL表达式
充当html的标签的属性来表达
<a th:text="${变量名}"></a>
2.选择表达式
用一个预先选择的对象来代替上下文变量容器(map)来执行
3.文字国际化表达式
4.url表达式
本次上课内容
<!--这个是正确的-->
<div th:text="${k1}">aaa</div><br/>
或者
<div th:text="${user.id}"></div>
------------------------------------------------
<div>
<!--这个是错误的-->
<p>user.id:[[user.id]]</p>
<!--这个是正确的-->
<p>user.userName:[[${user.userName}]]</p>
<p>user.password:[[${user.password}]]</p>
</div>
------------------------------------------
<!--这个是错误的-->
错误示范:<div>[[k1]]</div>
<!--这个是正确的-->
<div>[[${k1}]]</div>
-----------转义字符------------
<a th:text="${text1}"></a>
<br/>
正常的<p>是无法显示的
controller内容
运行效果:(注<p> 直接变成段落标签,而不是直接输出<p> 这个内容)
标签:springboot,值到,2cp,Thymeleaf,k1,user,password,id,表达式 来源: https://blog.csdn.net/wudingan/article/details/100585314