Search code examples
javajspstruts2ognlvaluestack

Getter Property (without property and setter) Access Via ValueStack


public class MyAction extends ActionSupport
{
     public String getMyValue()
     {
          return "SomeText";
     }
     ...
}

I have this MyAction class. Now, the question is that when I refer myValue in my JSP page using OGNL, will it create the myValue property on ValueStack, or will it just call the getter method?


Solution

  • It will call a getter method. The OGNL when evaluating an expression finding a property accessor corresponding to the name of the property. It's doing it using reflection on the method basis via prefixing "get"/"set" to the name of the property.