Skip to content

SpEL support for bean property access via square brackets [SPR-6968] #11633

@spring-projects-issues

Description

@spring-projects-issues

Scott Andrews opened SPR-6968 and commented

SpEL currently supports using square brackets '[]' to allow indexed access to arrays and maps. It should also support property lookups on objects. JSP/Unified EL supports this syntax.

For example:

where 'object' is a bean with a method getFoo() { return "bar"; }
and 'field' is string "foo"

#{object[field]}
should resolve to "bar"

Currently, this expression results in a NumberFormatException attempting to coerce "foo" to an integer.

A good general rule of thumb for square brackets should be that unless the target type is an array (or array like), the result of the sub expression in the brackets should be evaluated against the target as if it were attached to the target with a dot '.'


Affects: 3.0.1

Issue Links:

  • ROO-689 display.tagx should use <spring:eval /> instead of <c:out /> to use custom converters ("is depended on by")

Referenced from: commits 81b10be

1 votes, 1 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions