本文介绍了Getter Property(没有属性和setter)通过ValueStack访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class MyAction extends ActionSupport
{
public String getMyValue()
{
return "SomeText";
}
...
}
我有这个 MyAction
类。现在,问题是当我使用OGNL在我的JSP页面中引用 myValue
时,它是否会创建 myValue
属性 ValueStack
,还是只调用getter方法?
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?
推荐答案
它将调用getter方法。 OGNL在评估表达式时查找与属性名称对应的属性访问器。它通过在get
/ set
前缀为该属性的名称,在方法基础上使用反射来实现。
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.
这篇关于Getter Property(没有属性和setter)通过ValueStack访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!