Prateek Prateek - 1 year ago 159
Java Question

How to specify multiple values in list key attribute of select tag in struts2

Select tag in jsp is containing list of Plan objects

Here is a Plan class

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" />

Now i want
listkey to have multiple values separated by comma like(packageId,price)

How can i achieve this ?

Answer Source

Simply specify it in the key attribute:

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

And (if you are not using a recent version) use cssClass instead of class in Struts Tags.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download