title: How can I map multiple values from select tag in Struts 2?
body: <p>I have a multi-selection combo in my Struts2 web application. I use the ui-multisection component. When I select and submit values <code>"1"</code> and <code>"2"</code> then check it in my action class, only the last selected value was set. What should I do for getting set all selected values? </p>
  
  <p><strong>JSP File :</strong></p>
  
  <pre><code>&lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;link rel="stylesheet"
      href="&lt;s:url value="/css/jquery.multiselect.css"/&gt;" type="text/css" /&gt;
  &lt;link rel="stylesheet"
      href="&lt;s:url value="/css/jquery.multiselect.filter.css"/&gt;"
      type="text/css" /&gt;
  &lt;link rel="stylesheet"
      href="&lt;s:url value="/css/themes/base/jquery.ui.theme.css"/&gt;"
      type="text/css" /&gt;
  &lt;script type="text/javascript"
      src="&lt;s:url value="/js/jquery-1.9.1.min.js" /&gt;"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"
      src="&lt;s:url value="/js/jquery-ui.min.js" /&gt;"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"
      src="&lt;s:url value="/js/jquery.multiselect.min.js" /&gt;"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"
      src="&lt;s:url value="/js/jquery.multiselect.filter.js" /&gt;"&gt;&lt;/script&gt;
  
  
  &lt;script language="javascript"&gt;
      $(function() {
  
          $("select").multiselect({
              multiple : true,
              selectedList : 4,
              noneSelectedText : 'Tous',
              height : 180
          });
  
          $("select").multiselect().multiselectfilter();
      });
  &lt;/script&gt;
  &lt;s:form id="idForm" action="testOMB.do" name="myForm"&gt;
  
      &lt;div class="contentTable"&gt;
          &lt;div class="tbl"&gt;
  
              &lt;table width="100%"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;s:select id="idCombo1" multiple="multiple"
                              list="listItems" name="listIdSelected"
                              value="listIdSelected" listKey="id" listValue="label"
                              emptyOption="true" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="bloc_action"&gt;
          &lt;s:submit cssClass="btn_action" value="TEST OMB" /&gt;
      &lt;/div&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p><strong>Action class :</strong></p>
  
  <pre><code>package com.omb.controller.report;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.springframework.transaction.annotation.Isolation;
  import org.springframework.transaction.annotation.Propagation;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.omb.ui.item.Item;
  
  import com.opensymphony.xwork2.ActionSupport;
  import com.opensymphony.xwork2.Preparable;
  
  @SuppressWarnings("serial")
  public class MyAction extends ActionSupport implements Preparable {
  
      Log log = LogFactory.getLog(MyAction.class);
  
      private List&lt;Item&gt; listItems = new ArrayList&lt;String&gt;();
      private List&lt;String&gt; listIdSelected = new ArrayList&lt;String&gt;();
  
      public void prepare() throws Exception {
          listItems.add(new Item("1", "Item 1"));
          listItems.add(new Item("2", "Item 2"));
          listItems.add(new Item("3", "Item 3"));
          listItems.add(new Item("4", "Item 4"));
      }
  
      @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = true)
      public String testOMB() throws Exception {
          log.debug("listIdSelected = " + listIdSelected.size());
          return SUCCES;
      }
  
      public List&lt;Item&gt; getListItems() {
          return this.listItems;
      }
  
      public void setListItems(List&lt;Item&gt; listItems) {
          this.listItems = listItems;
      }
  
      public List&lt;String&gt; getListIdSelected() {
          return this.listIdSelected;
      }
  
      public void setListIdSelected(List&lt;String&gt; listIdSelected) {
          this.listIdSelected = listIdSelected;
      }
  
  
  }
  </code></pre>
  
  <p><strong>The <code>struts.xml</code> file:</strong></p>
  
  <pre><code>?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;!DOCTYPE struts PUBLIC
      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
      "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  &lt;struts&gt;
      &lt;constant name="struts.devMode" value="false" /&gt;
      &lt;constant name="struts.action.extension" value="do" /&gt;
      &lt;constant name="struts.custom.i18n.resources"
          value="com.omb.i18n.StrutsResourceBundle" /&gt;
      &lt;constant name="struts.objectFactory" value="spring" /&gt;
      &lt;constant name="struts.objectFactory.spring.autoWire" value="name" /&gt;
      &lt;constant name="struts.i18n.encoding" value="ISO-8859-1" /&gt;
      &lt;constant name="struts.i18n.reload" value="false" /&gt;
      &lt;constant name="struts.configuration.xml.reload" value="false" /&gt;
      &lt;constant name="struts.locale" value="fr" /&gt;
      &lt;constant name="struts.multipart.maxSize" value="100000000000" /&gt;
      &lt;constant name="struts.enable.SlashesInActionNames" value="true" /&gt;
      &lt;constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/&gt;
  
      &lt;constant name="struts.codebehind.classSuffix" value="Controller"/&gt;
      &lt;constant name="struts.codebehind.action.checkImplementsAction" value="false"/&gt;
      &lt;constant name="struts.codebehind.action.checkAnnotation" value="false"/&gt;
      &lt;constant name="struts.codebehind.action.defaultMethodName" value="index"/&gt;
      &lt;constant name="struts.configuration.classpath.defaultParentPackage" value="rest-default" /&gt;
  
      &lt;package name="default" extends="tiles-default" namespace="/"&gt;
  
          &lt;interceptors&gt;
  
              &lt;interceptor name="userAware"
                  class="com.omb.interceptor.UserAwareInterceptor" /&gt;
  
              &lt;interceptor name="params-filter"
                  class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor" /&gt;
  
              &lt;interceptor-stack name="defaultStack"&gt;
                  &lt;interceptor-ref name="exception" /&gt;
                  &lt;interceptor-ref name="alias" /&gt;
                  &lt;interceptor-ref name="servletConfig" /&gt;
                  &lt;interceptor-ref name="i18n" /&gt;
                  &lt;interceptor-ref name="chain" /&gt;
                  &lt;interceptor-ref name="modelDriven" /&gt;
                  &lt;interceptor-ref name="fileUpload"&gt;
                      &lt;param name="maximumSize"&gt;11204928&lt;/param&gt;
                  &lt;/interceptor-ref&gt;
                  &lt;interceptor-ref name="staticParams" /&gt;
                  &lt;interceptor-ref name="conversionError" /&gt;
                  &lt;interceptor-ref name="params" /&gt;
                  &lt;interceptor-ref name="prepare" /&gt;
                  &lt;interceptor-ref name="validation" /&gt;
                  &lt;interceptor-ref name="workflow" /&gt;
                  &lt;interceptor-ref name="userAware" /&gt;
  
              &lt;/interceptor-stack&gt;
  
          &lt;/interceptors&gt;
  
          &lt;default-interceptor-ref name="defaultStack" /&gt;
  
          &lt;global-results&gt;
              &lt;result name="technicalError" type="chain"&gt;
                  errorAction
              &lt;/result&gt;
              &lt;result name="sessionInvalidError" type="tiles"&gt;
                  sessionInvalid
              &lt;/result&gt;
              &lt;result name="blank" type="tiles"&gt;blank&lt;/result&gt;
          &lt;/global-results&gt;
  
          &lt;global-exception-mappings&gt;
              &lt;exception-mapping exception="java.lang.Exception"
                  result="technicalError" /&gt;
              &lt;exception-mapping
                  exception="com.omb.service.exception.UserSessionInvalidException"
                  result="sessionInvalidError" /&gt;
  
          &lt;/global-exception-mappings&gt;
  
          &lt;action name="errorAction"
              class="com.omb.controller.ErrorAction"&gt;
              &lt;result name="success" type="tiles"&gt;errorTile&lt;/result&gt;
          &lt;/action&gt;
  
          &lt;action name="*Cache"
              class="com.omb.controller.CacheAction" method="{1}"&gt;
              &lt;result name="success" type="tiles"&gt;resultCache&lt;/result&gt;
              &lt;result name="input" type="tiles"&gt;inputCache&lt;/result&gt;
          &lt;/action&gt;
  
          &lt;action name="*Login"
              class="com.omb.controller.LoginAction" method="{1}"&gt;
              &lt;result name="success" type="tiles"&gt;login&lt;/result&gt;
              &lt;result name="password" type="tiles"&gt;changePassword&lt;/result&gt;
          &lt;/action&gt;
  
          &lt;action name="*Welcome"
              class="com.omb.controller.WelcomeAction" method="{1}"&gt;
              &lt;result name="success" type="tiles"&gt;welcome&lt;/result&gt;
              &lt;result name="report" type="redirectAction"&gt;
                  &lt;param name="namespace"&gt;/report&lt;/param&gt;
                  &lt;param name="actionName"&gt;perimetersReport&lt;/param&gt;
              &lt;/result&gt;
          &lt;/action&gt;
  
      &lt;/package&gt;
  
      &lt;package name="report" extends="default" namespace="/report"&gt;
          &lt;action name="*Action"
              class="com.omb.controller.report.MyAction"
              method="{1}"&gt;
              &lt;result name="succes" type="tiles"&gt;succesTile&lt;/result&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>