Syntax error with "?." - Malformed OGNL expression

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax error with "?." - Malformed OGNL expression

Thibault Duchateau
This post was updated on .
Hi guys,

In one of my tests, I'm getting a "ognl.ExpressionSyntaxException: Malformed OGNL expression" with this kind of syntax:

${person?.id}

Looking at the debug logs, I can see that the StandardDialect is being used...
[THYMELEAF] * Dialect [1 of 2]: org.thymeleaf.standard.StandardDialect
...whereas I've configured the Spring3's one:

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
   <property name="templateResolver" ref="templateResolver" />
   <property name="additionalDialects">
      <set>
         <bean class="com.github.dandelion.datatables.thymeleaf.dialect.DataTablesDialect" />
      </set>
   </property>
</bean>

Of course, Thymeleaf-spring3 is present in the classpath.

I can't seem to find any mention of this syntax in the docs.
So I'm not sure if this syntax is provided by one the Spring dialects or not.

Does anyone have any idea?

EDIT: Thymeleaf 2.1.3.RELEASE

Thanks!

Regards,
Thibault.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error with "?." - Malformed OGNL expression

Emanuel
Administrator
That syntax looks like the Groovy safe navigation operator (if person is not null, return person.id, else return null) http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html#expressions-operator-safe-navigation

I can't find a mention of it in the OGNL docs, so I think it's a Spring thing.  Weird that the Spring dialect doesn't seem to be in use though.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error with "?." - Malformed OGNL expression

Markus
In reply to this post by Thibault Duchateau
Funny thing is that I run in the same problem, though I _want_ to use OGNL:

    <li th:if="${foo?.bar}">Another Item</li>

throws an

    ognl.ExpressionSyntaxException: Malformed OGNL expression: foo?.bar [ognl.ParseException: Encountered " "." ". "" at line 1, column 5.

Am I missing something? According to the OGNL docs, this should work.


Puzzled,

Markus