1. js里不能有一些符号的问题(例如小于还是大于来着)
解:在Thymeleaf文档里能知道,js要搞成这样:
<script th:inline="javascript">
/*<![CDATA[*/
...
var username = /*[[${session.user.name}]]*/ 'Sebastian';
...
/*]]>*/
</script>
在那个CDATA什么的里面就能随便写了
2.html里不能有<的问题
解:用转义符<,文档里也有写
4.9 Comparators and Equality
Values in expressions can be compared with the >
, <
, >=
and <=
symbols, as usual, and also the ==
and !=
operators can be used to check equality (or the lack of it). Note that XML establishes that the <
and >
symbols should not be used in attribute values, and so they should be substituted by <
and >
.
th:if="${prodStat.count} > 1"
th:text="'Execution mode is ' + ( (${execMode} == 'dev')? 'Development' : 'Production')"
Note that textual aliases exist for some of these operators: gt
(>
), lt
(<
), ge
(>=
), le
(<=
), not
(!
). Also eq
(==
), neq
/ne
(!=
).
3.thymeleaf不管自定义属性的问题。
例如希望<span th:faefasefsf="${biu}"></span>,结果在生成的页面的源代码里,这个仍然是th:...而不会像其他的th:value一样变成value,因为thymeleaf不管自定义的属性。
解:
<span th:attr="asefseaff='1241412'"></span>
生成的源代码:
<spanasefseaff="1241412"></span>
(只是快速简单地写了一些之前遇到的问题,并不详细)
(待续)