If I have the expression: obj1.obj2.obj3
And obj2 is null, then expression fails with an exception. Is there any way to configure SpEL to just return null?
You should use safe navigation operator that is ?.
(in your example that'd be obj1?.obj2?.obj3
) to avoid nasty NullPointerException
while navigating graph of beans.
You can find detailed explanation and some examples in chapter 6.5.15 Safe Navigation operator of reference
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