jsp上不显示名称
问题描述:
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上不显示名称
但是,当我在JSP上显示时,它不显示组名,它是显示带有包的类名称。
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="list">
<s:property value="customerGroup"/>
</s:iterator>
答
因为控制台您正在使用, 明确的System.out.println打印的名称( “客户集团” + customerRecord.getCustomerGroup()getGroupName());
而且在JSP你只是打印customerGroup
<s:property value="customerGroup"/>
这当然是不同的。
试试这个,而不是
<s:property value="customerGroup.groupName"/>
答
我认为你有一个像类:
class CustomerGroup {
private String groupName;
public String getGroupName()
{
return groupName;
}
public void setGroupName(String str)
{
this.groupName = str;
}
}
,你的列表是List<CustomerGroup>
;所以你只能用:
<s:property value="groupName"/>
希望对你有帮助。
答
这只针对您如何尝试使用OGNL.weather您尝试使用OGNL来引用CustomerGroup propery,或者如果您想访问个别元素