名称未显示在 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 上显示时,它不显示组名称,而是显示类名称带包。
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="list">
<s:property value="customerGroup"/>
</s:iterator>
private CustomerGroup customerGroup;
public CustomerGroup getCustomerGroup () {
return customerGroup;
}
public void setCustomerGroup (CustomerGroup customerGroup) {
this.customerGroup= customerGroup;
}
When I print customerGroup
it shows group name which is fine. System.out.println("Customer Group is "+customerRecord.getCustomerGroup().getGroupName());
But when I display on JSP it doesn't show the group name, it is show class name with package.
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:iterator value="list">
<s:property value="customerGroup"/>
</s:iterator>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为在控制台上您明确打印名称,
System.out.println("客户组为"+customerRecord.getCustomerGroup().getGroupName());
在 JSP 中,您只是打印
customerGroup
这当然是不同的。
试试这个
Because on console you are explicitly printing the name using,
System.out.println("Customer Group is "+customerRecord.getCustomerGroup().getGroupName());
And in JSP you are just printing the
customerGroup
Which is of course different.
Try this, instead
我认为您有一个类似的类:
并且您的列表是
List
;所以你只能使用:希望对你有帮助。
I think you have a class like:
and your list is
List<CustomerGroup>
; so you can only use:hope helpful to you.
这仅特定于您尝试使用 OGNL 的方式。weather 您尝试使用 OGNL 来引用 CustomerGroup 属性或者如果您想访问单个元素
That is only specific to how you are trying to use OGNL.weather you are trying touse OGNL to refer to the CustomerGroup propery or if you want to access individual elemets