How declare a variable using another variable in thymeleaf? This is what I want to do:
<div th:with="var1='blablabla'">
<div th:with="var2=${${var1} == null ? '' : 's'}">
<span th:utext="${tmpCustomerType}">show var2</span>
</div>
</div>
but the compilator doesn't like that ${var1}
:
EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
(org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "${ccc} == null ? '' : ${ccc}" (custom:24))
You have bad el expression. Maybe these.
<div th:with="var1='blablabla'">
<div th:with="var2=var1 == null? '' : 's'">
<span th:utext="${tmpCustomerType}">show var2</span>
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.