У меня есть приложение SpringBoot 2.1.4.RELEASE RESTful Web Service, использующее Spring Initializer, встроенный Tomcat, шаблонизатор Thymeleaf и пакет в качестве исполняемого файла JAR.
У меня есть этот фрагмент кода водин из моих шаблонов,
<tr th:each="menuPriceSummary: ${menus}" >
...
<a href="#" th:onclick="|changeAIColor('idAwesomeIconFAV${menuPriceSummary.menu.symbol}');| + 'performAjaxCall(\'' + @{/allmenupricesummary/switchfav/{id}(id=${menuPriceSummary.menu.symbol})} + '\');'" >
<span th:if="${menuPriceSummary.favorited}">
<i th:id="'idAwesomeIconFAV'+${menuPriceSummary.menu.symbol}" class="fa fa-toggle-on fa-lg" style="color:#009900; text-align: center;" aria-hidden="true"></i>
</span>
<span th:if="${!menuPriceSummary.favorited}">
<i th:id="'idAwesomeIconFAV'+${menuPriceSummary.menu.symbol}" class="fa fa-toggle-off fa-lg" style="color:#e6e6e6;" aria-hidden="true"></i>
</span>
</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 textual data from variables should better be output to "data-*" attributes and then read from the event handler.