String Concatenation in EL [duplicate]

2019-01-13 14:30发布

This question already has an answer here:

I would like to concatenate a string within a ternary operator in EL(Expression Language).

Suppose there is a variable named value. If it's empty, I want to use some default text. Otherwise, I need to append it with some static text.

${(empty value)? "none" : value + " enabled"}

This will not compile however. What would be a correct way to write this? Or is this even possible?

7条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-13 15:22

Mc Dowell's answer is right. I just want to add an improvement if in case you may need to return the variable's value as:

${ empty variable ? '<variable is empty>' : variable }
查看更多
登录 后发表回答