Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Mar 10, 2010 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

Indexing used to be all powerful (ranges/etc). It was trimmed down for 3.0 - perhaps too much as issues like this show. This is now fixed and I've also addressed the setting case too "foo[bar]=5".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants