new*_*bie 8 struts2 ognl java-ee
美好的一天!
我正在阅读Manning的struts2书,其中一个主题是使用语法使用OGNL访问静态变量 @[fullClassName]@[property or methodCall]
所以我在我的程序上尝试了它,我的代码如下:
豆:
public class ContactsBean {
private static int count = 1;
//getter and setter
}
Run Code Online (Sandbox Code Playgroud)
行动:
private ContactsBean contacts;
//getters and setters
Run Code Online (Sandbox Code Playgroud)
JSP:
<s:property value="@com.demo.bean.ContactsBean@count" />
or
<s:property value="@vs@count" /> //valuestack method
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我错过了什么吗?谢谢.
lsc*_*hin 13
@see OGNL Basics:访问静态属性
豆:
public class ContactsBean {
private static int count = 1;
// static getter
// setter
}
Run Code Online (Sandbox Code Playgroud)
<s:property value="@com.demo.bean.ContactsBean@getCount()" />
Run Code Online (Sandbox Code Playgroud)
其他情况
public class ContactsBean {
public static final int SCALE = 50;
}
Run Code Online (Sandbox Code Playgroud)
<s:property value="@com.demo.bean.ContactsBean@SCALE" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11794 次 |
| 最近记录: |