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。
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="list">
<s:property value="customerGroup"/>
</s:iterator>
答案 0 :(得分:0)
因为在控制台上您使用明确打印名称, System.out.println(“Customer Group is”+ customerRecord.getCustomerGroup()。getGroupName());
在JSP中,您只是打印customerGroup
<s:property value="customerGroup"/>
当然不同。
试试这个,而不是
<s:property value="customerGroup.groupName"/>
答案 1 :(得分:0)
我认为你有一个类:
class CustomerGroup {
private String groupName;
public String getGroupName()
{
return groupName;
}
public void setGroupName(String str)
{
this.groupName = str;
}
}
,您的列表为List<CustomerGroup>
;所以你只能使用:
<s:property value="groupName"/>
希望对你有所帮助。
答案 2 :(得分:0)
这仅限于您尝试使用OGNL.weather的方式,您尝试使用OGNL来引用CustomerGroup属性或者如果您想要访问单个元素