我是 Struts 新手,我想在 JSP 中访问 Action
类中的一些值。我如何访问这些值?
public static String[] getSoldItemsColNames() {
return SellerHistory.soldItemsColNames;
}
public ItemType[] getActiveItems() {
return sellerHistory.getActiveItems();
}
这就是我正在尝试的方法。
<s:iterator value="soldItemsColNames" status="soldItemsColNames" var="element">
<th><s:property value="%{#element}" /></th>
</s:iterator>
最佳答案
这是我的程序 - 完美运行:
Action class :
static Account[] account=new Account[1];
static String[] arrayofStrings={"1","2","4"};
{
Account a=new Account();
a.setName(arrayofStrings);
account[0]=a;
}
//..getters and setters , execute()
public String[] getArrayofStrings() {
return this.account[0].getName();//Just like yours
}
JSP 逻辑
<s:iterator value="arrayofStrings" status="true" var="element">
<p><s:property value="%{#element}" /></p>
</s:iterator>
关于java - 在 JSP 中访问操作 getter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15169846/