-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Ralph Schaer opened SPR-9123 and commented
Looks like SpEL has a problem with property names where the second character is uppercase.
public class TestObject {
private String iD;
}
According to the Java Bean Specification the get and set method have to be named like this. This is also the code Eclipse generates with the "Source->Generate Getters and Setters" function.
public String getiD() {
return iD;
}
public void setiD(String iD) {
this.iD = iD;
}
Now I try to access the property iD with SpEL
TestObject to = new TestObject();
to.setiD("a ID");
ExpressionParser expressionParser = new SpelExpressionParser();
Expression idExpression = expressionParser.parseExpression("iD");
String anId = idExpression.getValue(to, String.class);
This code throws an exception
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'iD' cannot be found on object of type 'TestObject'
The PropertyUtils class from the Apache commons-beanutils project works:
PropertyUtils.getProperty(to, "iD")
Affects: 3.1.1
Issue Links:
- Fix SpEL JavaBean compliance for setters [SPR-10122] #14755 Fix SpEL JavaBean compliance for setters
- Relax JavaBean rules for SpEL property access [SPR-10716] #15344 Relax JavaBean rules for SpEL property access
Referenced from: commits d91a419, 0ca11d2, 1f28bdf
1 votes, 3 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug