Getter Property (without property and setter) Acce

2019-06-02 01:21发布

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?

1条回答
Fickle 薄情
2楼-- · 2019-06-02 01:39

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.

查看更多
登录 后发表回答