Getter Property (without property and setter) Access Via ValueStack

*爱你&永不变心* 提交于 2020-01-03 03:21:22

问题


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:


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.



来源:https://stackoverflow.com/questions/26752434/getter-property-without-property-and-setter-access-via-valuestack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!