2014-01-10 48 views
2

在JSP選擇標籤指定選擇標籤的列表關鍵屬性多個值是含計劃的對象列表如何在Struts2

這裏是一個計劃類

public class Plan { 

    private String packageId; 
    private String packageName; 
    private String price; 

    public String getPackageId() { 
     return packageId; 
    } 
    public void setPackageId(String packageId) { 
     this.packageId = packageId; 
    } 
    public String getPackageName() { 
     return packageName; 
    } 
    public void setPackageName(String packageName) { 
     this.packageName = packageName; 
    } 

    public String getPrice() { 
     return price; 
    } 
    public void setPrice(String price) { 
     this.price = price; 
    } 
} 

<s:select theme="simple" list="%{#request.packageList}" listKey="packageId" 
    listValue="packageName" headerKey="0" headerValue="--Select--" 
    name="packageID" class="dropdowm" id="packageID" /> 

現在我想listkey to have multiple values separated by comma like(packageId,price)

我該如何做到這一點?

回答

2

在關鍵屬性只需指定它:

<s:select theme = "simple" 
      list = "%{#request.packageList}" 
     listKey = "packageId + ',' + price" 
     listValue = "packageName" 
     headerKey = "0" 
    headerValue = "--Select--" 
      name = "myNewCustomKey" 
     cssClass = "dropdowm" 
      id = "packageID" /> 

和(如果你使用的是最新的版本是)在Struts標籤使用cssClass代替class