小编And*_*tte的帖子

(Spring) th:with 基于条件

我想根据条件在 thymeleaf 中分配一个变量:

<span th:with="valueID=${${myField != null} ? {myField.value.getId()}}">
Run Code Online (Sandbox Code Playgroud)

这不起作用,并给了我一个例外:

"Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: `"${myField == null} ? {myField.value.getId()}"`"
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

事实上,我想在 myField 不存在时设置valueID为。{myField.value.getId()}null

java spring spring-mvc thymeleaf spring-boot

5
推荐指数
1
解决办法
627
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-mvc ×1

thymeleaf ×1