https://somefuture.iteye.com/blog/2253761
Thymeleaf的内置属性
博客分类:
SpringBoot
Thymeleaf
血泪体验
thymeleaf
Thymeleaf是另一个Java视图模板引擎,使用上和FreeMarker各有千秋,不了解的可以从其他博文里学习一下。我这里主要记录一下它的内置属性。
本文不是Thymeleaf入门教程,也不是对其标签进行全面讲解只对其属性等价标签进行记录,以为辞典。
Thymeleaf提供了一个标签th:attr,可以把多个DOM标签用逗号分隔后写进去:
th:attr="src=@{/images/gtvglogo.png},title=#{logo},alt=#{logo}" />
这个例子里给标签设置了三个属性标签:src、title、alt。自带的src会被Thymeleaf处理后扔掉而使用自己的。
这个标签不太优雅,不仅写起来紊乱,读起来也凌乱。所以很少用,一般用其他的代替:
th:src="@{/images/gtvglogo.png}" th:title="#{logo}" th:alt="#{logo}" />
作为th:attr的实例用法,Thymeleaf提供了几乎全部标签的Thymeleaf等价标签:
th:abbrth:acceptth:accept-charset
th:accesskeyth:actionth:align
th:altth:archiveth:audio
th:autocompleteth:axisth:background
th:bgcolorth:borderth:cellpadding
th:cellspacingth:challengeth:charset
th:citeth:classth:classid
th:codebaseth:codetypeth:cols
th:colspanth:compactth:content
th:contenteditableth:contextmenuth:data
th:datetimeth:dirth:draggable
th:dropzoneth:enctypeth:for
th:formth:formactionth:formenctype
th:formmethodth:formtargetth:frame
th:frameborderth:headersth:height
th:highth:hrefth:hreflang
th:hspaceth:http-equivth:icon
th:idth:keytypeth:kind
th:labelth:langth:list
th:longdescth:lowth:manifest
th:marginheightth:marginwidthth:max
th:maxlengthth:mediath:method
th:minth:nameth:optimum
th:patternth:placeholderth:poster
th:preloadth:radiogroupth:rel
th:revth:rowsth:rowspan
th:rulesth:sandboxth:scheme
th:scopeth:scrollingth:size
th:sizesth:spanth:spellcheck
th:srcth:srclangth:standby
th:startth:stepth:style
th:summaryth:tabindexth:target
th:titleth:typeth:usemap
th:valueth:valuetypeth:vspace
th:widthth:wrapth:xmlbase
th:xmllangth:xmlspace
比如: