private CustomerGroup customerGroup;
public CustomerGroup getCustomerGroup () {
return customerGroup;
}
public void setCustomerGroup (CustomerGroup customerGroup) {
this.customerGroup= customerGroup;
}当我打印customerGroup时,它显示了组名称,这是可以接受的。System.out.println("Customer Group is "+customerRecord.getCustomerGroup().getGroupName());
但是当我在JSP上显示时,它没有显示组名,而是show class name with package。
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="list">
<s:property value="customerGroup"/>
</s:iterator>发布于 2010-12-01 14:17:38
因为在控制台上,您显式地使用System.out.println("Customer Group is "+customerRecord.getCustomerGroup().getGroupName());“)打印名称
而在JSP中,您只需打印customerGroup
<s:property value="customerGroup"/>这当然是不同的。
试试这个吧。
<s:property value="customerGroup.groupName"/>发布于 2010-12-01 14:56:10
我认为你有一个这样的类:
class CustomerGroup {
private String groupName;
public String getGroupName()
{
return groupName;
}
public void setGroupName(String str)
{
this.groupName = str;
}
}而您的列表是List<CustomerGroup>;因此您只能使用:
<s:property value="groupName"/>希望能对你有所帮助。
发布于 2010-12-01 18:29:54
这只适用于您尝试使用OGNL.weather的方式,您尝试使用OGNL来引用CustomerGroup属性,或者您想要访问单个elemets
https://stackoverflow.com/questions/4321688
复制相似问题