如何在 thymeleaf 中使用另一個變量聲明一個變量?這就是我想做的:<div th:with="var1='blablabla'"> <div th:with="var2=${${var1} == null ? '' : 's'}"> <span th:utext="${tmpCustomerType}">show var2</span> </div></div>但編譯器不喜歡這樣${var1}:EL1041E:(pos 1): 解析有效表達式后,表達式中還有更多數據:'lcurly({)'(org.thymeleaf.exceptions.TemplateProcessingException: 計算 SpringEL 表達式時出現異常:“${ccc} == null ? '' : ${ccc}" (自定義:24))
1 回答

弒天下
TA貢獻1818條經驗 獲得超8個贊
你的表情很糟糕。也許這些。
<div th:with="var1='blablabla'">
<div th:with="var2=var1 == null? '' : 's'">
<span th:utext="${tmpCustomerType}">show var2</span>
</div>
</div>
添加回答
舉報
0/150
提交
取消