在html 引入
注意:html 中的标签必须严格规范,标签必须闭合,即
技术或者类似结束
语法
${user.name} 使用会话属性
@{} <link rel="stylesheet" type="text/css" media="all"href="../../css/gtvg.css" th:href="@{/css/gtvg.css}" />
– –
${} 中预存对象(表达式中基本对象)
param 获取请求参数,比如${param.name},http://localhost:8080?name=jeff
session 获取 session 的属性
application 获取 application 的属性
execInfo 有两个属性 templateName和 now(是 java 的 Calendar 对象)
ctx
vars
locale
httpServletRequest
httpSession
– –
th扩展标签
th:text 普通字符串
th:utext 转义文本
th:href
th:attr <img src="../../images/gtvglogo.png" th:attr="src=@{/images/gtvglogo.png},title=#{logo},alt=#{logo}" />
th:with 定义常量
th:attrappend
th:classappend
th:styleappend
其他th标签
th:abbr th:accept th:accept-charset
th:abbr th:accept th:accept-charset
th:accesskey th:action th:align
th:alt th:archive th:audio
th:autocomplete th:axis th:background
th:bgcolor th:border th:cellpadding
th:cellspacing th:challenge th:charset
th:cite th:class th:classid
th:codebase th:codetype th:cols
th:colspan th:compact th:content
th:contenteditable th:contextmenu th:data
th:datetime th:dir th:draggable
th:dropzone th:enctype th:for
th:form th:formaction th:formenctype
th:formmethod th:formtarget th:frame
th:frameborder th:headers th:height
th:high th:href th:hreflang
th:hspace th:http-equiv th:icon
th:id th:keytype th:kind
th:label th:lang th:list
th:longdesc th:low th:manifest
th:marginheight th:marginwidth th:max
th:maxlength th:media th:method
th:min th:name th:optimum
th:pattern th:placeholder th:poster
th:preload th:radiogroup th:rel
th:rev th:rows th:rowspan
th:rules th:sandbox th:scheme
th:scope th:scrolling th:size
th:sizes th:span th:spellcheck
th:src th:srclang th:standby
th:start th:step th:style
th:summary th:tabindex th:target
th:title th:type th:usemap
th:value th:valuetype th:vspace
th:width th:wrap th:xmlbase
th:xmllang th:xmlspace th:alt-title 或th:lang-xmllang(如果其中两个属性值相同)
//对象
<div th:Object="${most}">
//对象的属性
<p th:text="*{name}"></p>
</div>
循环
//循环
<tr th:each="person,iterStat:${most}"
//三目运算
th:style="${iterStat.odd}?'background-color:red' :''"
>
<td th:text="${person.country}"></td>
<td th:text="${person.name}"></td>
<td th:text="${person.desc}"></td>
</tr>
可以继承页面
A页面
<div th:fragment="myhead">
// 在这引入jquery
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<p>我是头</p>
</div>
B页面
//引入A页面
<div th:include="head :: myhead">
</div>
jquery 也会继承
<script type="text/javascript">
alert($)</script>
我是身体