Allow SpelCompiler to compile MapAccessor expressions [SPR-13638] #18215
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Daniel Fernández opened SPR-13638 and commented
Thymeleaf 3.0 will modify the way in which SpEL expressions are executed inside templates.
One of the modifications will be that the context object (containing all the variables usable in expressions) will be passed to the SpEL evaluation engine wrapped as a Map, so that for most expressions (though not all), the use of custom PropertyAccessor will not be needed. And that's good because that's one of the conditions for the SpEL compiler to be able to run.
The problem is, a good amount of expressions in Thymeleaf templates look like:
The "someproperty" part (which will internally use introspection on the "someobject" object) should be covered by the SpEL compiler... but the first part of the expression, "someobject", is obtained from a (wrapped) map. So in this case, given the expression includes the use of a non-introspection-based accessor, compilation is not performed at all.
It would be great therefore if the use of MapAccessor was included in the SpEL compiler capabilities, so that expressions as the one above could be compiled in Thymeleaf 3.0 templates (if the compiler is configured).
Of course, this would make expressions such as:
...which might be even more common, to be compilable too. But in such case no introspection is involved, so I doubt we would obtain any real performance gain. That's why I focus on two-level expressions.
Affects: 4.2.2
The text was updated successfully, but these errors were encountered: