Home > Back-end >  Why am I getting an "ExpressionSyntaxException: Malformed OGNL expression" when using Thym
Why am I getting an "ExpressionSyntaxException: Malformed OGNL expression" when using Thym

Time:02-16

For some reason I'm getting an ExpressionSyntaxException: Malformed OGNL expression when using Thymeleaf's safe navigation operator (${inter.someObj?.field}). No issues if I get rid of the operator. Spring-boot 2.6.2, thymeleaf 3.0.14. Project is setup using Thymeleaf's OGNL and not the spring-boot-starter-thymeleaf with SpEl apparently. Does somebody know why am I getting this? And (hopefully) how to get rid of it?

CodePudding user response:

According to https://northcoder.com/post/thymeleaf-vs-spel-vs-ognl/ the safe navigation operator is only available when using the Spring Expression Language:

SpEL offers several enhancements which are not available in OGNL - and therefore not available in the Thymeleaf standard dialect. For example, it has the safe navigation operator, which provides a convenient way to handle null values when evaluating expressions.

  • Related