I want to create a Spring EL in which I want that two integers be concatenated as a-b
with a
and b
being integers. Spring EL does not support concat
function with integers as they are not String
s. I have tried to cast them like #T(java.lang.String).valueOf(user.id).concat('-').concat(#T(java.lang.String).valueOf(user.serviceId))
but this is not working.
What should be the correct expression?
Please, use next expression #{T(java.lang.String).format('%d-%d', user.id, user.serviceId)}
.
Hope this helps.
Update.
If this expression will be used within @Cacheable(key)
field, please update expression in next way: T(java.lang.String).format('%d-%d', #user.id, #user.serviceId)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With