开发者

name are not displaying on jsp

开发者 https://www.devze.com 2023-01-27 13:35 出处:网络
private CustomerGroup customerGroup; public CustomerGroup getCustomerGroup () { return customerGroup; } public void setCustomerGroup (CustomerGroup customerGroup) {
    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>


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

<s:property value="customerGroup"/>

Which is of course different.

Try this, instead

<s:property value="customerGroup.groupName"/>


I think you have a class like:

class CustomerGroup {
  private String groupName;
  public String getGroupName()
  {
     return groupName;
  }
  public void setGroupName(String str)
  {
     this.groupName = str;
  }
}

and your list is List<CustomerGroup>; so you can only use:

<s:property value="groupName"/>

hope helpful to you.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消