在springboot2.x的环境中使用thymeleaf的onclick时,若安照如下方式使用onclick,就会报错TemplateProcessingException异常。
<tr th:each="region, regionStat: ${regions}">
<a th:attr="data-bind=${region.enName}" href="javascript:void(0);"
th:onclick="'changeSimpleCondition(\'regionEnName\', \'' + ${region.enName} + '\')'"
th:text="${region.cnName}"></a>
</tr>
报错如下:
org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could be rendered as a text literal. A typical case is HTML attributes for event handlers (e.g. "onload"), in which text