<bdo id='kN8qp'></bdo><ul id='kN8qp'></ul>
  • <i id='kN8qp'><tr id='kN8qp'><dt id='kN8qp'><q id='kN8qp'><span id='kN8qp'><b id='kN8qp'><form id='kN8qp'><ins id='kN8qp'></ins><ul id='kN8qp'></ul><sub id='kN8qp'></sub></form><legend id='kN8qp'></legend><bdo id='kN8qp'><pre id='kN8qp'><center id='kN8qp'></center></pre></bdo></b><th id='kN8qp'></th></span></q></dt></tr></i><div id='kN8qp'><tfoot id='kN8qp'></tfoot><dl id='kN8qp'><fieldset id='kN8qp'></fieldset></dl></div>

    1. <legend id='kN8qp'><style id='kN8qp'><dir id='kN8qp'><q id='kN8qp'></q></dir></style></legend>
      1. <small id='kN8qp'></small><noframes id='kN8qp'>

        <tfoot id='kN8qp'></tfoot>

        如何从 Struts 2 中的选择标记映射多个值?

        时间:2023-09-24
      2. <small id='1bXpN'></small><noframes id='1bXpN'>

        <i id='1bXpN'><tr id='1bXpN'><dt id='1bXpN'><q id='1bXpN'><span id='1bXpN'><b id='1bXpN'><form id='1bXpN'><ins id='1bXpN'></ins><ul id='1bXpN'></ul><sub id='1bXpN'></sub></form><legend id='1bXpN'></legend><bdo id='1bXpN'><pre id='1bXpN'><center id='1bXpN'></center></pre></bdo></b><th id='1bXpN'></th></span></q></dt></tr></i><div id='1bXpN'><tfoot id='1bXpN'></tfoot><dl id='1bXpN'><fieldset id='1bXpN'></fieldset></dl></div>
        • <legend id='1bXpN'><style id='1bXpN'><dir id='1bXpN'><q id='1bXpN'></q></dir></style></legend>
            • <bdo id='1bXpN'></bdo><ul id='1bXpN'></ul>

            • <tfoot id='1bXpN'></tfoot>

                    <tbody id='1bXpN'></tbody>
                  本文介绍了如何从 Struts 2 中的选择标记映射多个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 Struts2 Web 应用程序中有一个多选组合.我使用 ui-multisection 组件.当我选择并提交值 "1""2" 然后在我的操作类中检查它时,只设置了最后一个选择的值.我应该怎么做才能设置所有选定的值?

                  I have a multi-selection combo in my Struts2 web application. I use the ui-multisection component. When I select and submit values "1" and "2" then check it in my action class, only the last selected value was set. What should I do for getting set all selected values?

                  JSP 文件:

                  <%@ taglib prefix="s" uri="/struts-tags"%>
                  <link rel="stylesheet"
                      href="<s:url value="/css/jquery.multiselect.css"/>" type="text/css" />
                  <link rel="stylesheet"
                      href="<s:url value="/css/jquery.multiselect.filter.css"/>"
                      type="text/css" />
                  <link rel="stylesheet"
                      href="<s:url value="/css/themes/base/jquery.ui.theme.css"/>"
                      type="text/css" />
                  <script type="text/javascript"
                      src="<s:url value="/js/jquery-1.9.1.min.js" />"></script>
                  <script type="text/javascript"
                      src="<s:url value="/js/jquery-ui.min.js" />"></script>
                  <script type="text/javascript"
                      src="<s:url value="/js/jquery.multiselect.min.js" />"></script>
                  <script type="text/javascript"
                      src="<s:url value="/js/jquery.multiselect.filter.js" />"></script>
                  
                  
                  <script language="javascript">
                      $(function() {
                  
                          $("select").multiselect({
                              multiple : true,
                              selectedList : 4,
                              noneSelectedText : 'Tous',
                              height : 180
                          });
                  
                          $("select").multiselect().multiselectfilter();
                      });
                  </script>
                  <s:form id="idForm" action="testOMB.do" name="myForm">
                  
                      <div class="contentTable">
                          <div class="tbl">
                  
                              <table width="100%">
                                  <tr>
                                      <td><s:select id="idCombo1" multiple="multiple"
                                              list="listItems" name="listIdSelected"
                                              value="listIdSelected" listKey="id" listValue="label"
                                              emptyOption="true" /></td>
                                  </tr>
                              </table>
                          </div>
                      </div>
                  
                      <div class="bloc_action">
                          <s:submit cssClass="btn_action" value="TEST OMB" />
                      </div>
                  </s:form>
                  

                  动作类:

                  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<Item> listItems = new ArrayList<String>();
                      private List<String> listIdSelected = new ArrayList<String>();
                  
                      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<Item> getListItems() {
                          return this.listItems;
                      }
                  
                      public void setListItems(List<Item> listItems) {
                          this.listItems = listItems;
                      }
                  
                      public List<String> getListIdSelected() {
                          return this.listIdSelected;
                      }
                  
                      public void setListIdSelected(List<String> listIdSelected) {
                          this.listIdSelected = listIdSelected;
                      }
                  
                  
                  }
                  

                  struts.xml 文件:

                  The struts.xml file:

                  ?xml version="1.0" encoding="UTF-8" ?>
                  
                  <!DOCTYPE struts PUBLIC
                      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                      "http://struts.apache.org/dtds/struts-2.0.dtd">
                  <struts>
                      <constant name="struts.devMode" value="false" />
                      <constant name="struts.action.extension" value="do" />
                      <constant name="struts.custom.i18n.resources"
                          value="com.omb.i18n.StrutsResourceBundle" />
                      <constant name="struts.objectFactory" value="spring" />
                      <constant name="struts.objectFactory.spring.autoWire" value="name" />
                      <constant name="struts.i18n.encoding" value="ISO-8859-1" />
                      <constant name="struts.i18n.reload" value="false" />
                      <constant name="struts.configuration.xml.reload" value="false" />
                      <constant name="struts.locale" value="fr" />
                      <constant name="struts.multipart.maxSize" value="100000000000" />
                      <constant name="struts.enable.SlashesInActionNames" value="true" />
                      <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
                  
                      <constant name="struts.codebehind.classSuffix" value="Controller"/>
                      <constant name="struts.codebehind.action.checkImplementsAction" value="false"/>
                      <constant name="struts.codebehind.action.checkAnnotation" value="false"/>
                      <constant name="struts.codebehind.action.defaultMethodName" value="index"/>
                      <constant name="struts.configuration.classpath.defaultParentPackage" value="rest-default" />
                  
                      <package name="default" extends="tiles-default" namespace="/">
                  
                          <interceptors>
                  
                              <interceptor name="userAware"
                                  class="com.omb.interceptor.UserAwareInterceptor" />
                  
                              <interceptor name="params-filter"
                                  class="com.opensymphony.xwork2.interceptor.ParameterFilterInterceptor" />
                  
                              <interceptor-stack name="defaultStack">
                                  <interceptor-ref name="exception" />
                                  <interceptor-ref name="alias" />
                                  <interceptor-ref name="servletConfig" />
                                  <interceptor-ref name="i18n" />
                                  <interceptor-ref name="chain" />
                                  <interceptor-ref name="modelDriven" />
                                  <interceptor-ref name="fileUpload">
                                      <param name="maximumSize">11204928</param>
                                  </interceptor-ref>
                                  <interceptor-ref name="staticParams" />
                                  <interceptor-ref name="conversionError" />
                                  <interceptor-ref name="params" />
                                  <interceptor-ref name="prepare" />
                                  <interceptor-ref name="validation" />
                                  <interceptor-ref name="workflow" />
                                  <interceptor-ref name="userAware" />
                  
                              </interceptor-stack>
                  
                          </interceptors>
                  
                          <default-interceptor-ref name="defaultStack" />
                  
                          <global-results>
                              <result name="technicalError" type="chain">
                                  errorAction
                              </result>
                              <result name="sessionInvalidError" type="tiles">
                                  sessionInvalid
                              </result>
                              <result name="blank" type="tiles">blank</result>
                          </global-results>
                  
                          <global-exception-mappings>
                              <exception-mapping exception="java.lang.Exception"
                                  result="technicalError" />
                              <exception-mapping
                                  exception="com.omb.service.exception.UserSessionInvalidException"
                                  result="sessionInvalidError" />
                  
                          </global-exception-mappings>
                  
                          <action name="errorAction"
                              class="com.omb.controller.ErrorAction">
                              <result name="success" type="tiles">errorTile</result>
                          </action>
                  
                          <action name="*Cache"
                              class="com.omb.controller.CacheAction" method="{1}">
                              <result name="success" type="tiles">resultCache</result>
                              <result name="input" type="tiles">inputCache</result>
                          </action>
                  
                          <action name="*Login"
                              class="com.omb.controller.LoginAction" method="{1}">
                              <result name="success" type="tiles">login</result>
                              <result name="password" type="tiles">changePassword</result>
                          </action>
                  
                          <action name="*Welcome"
                              class="com.omb.controller.WelcomeAction" method="{1}">
                              <result name="success" type="tiles">welcome</result>
                              <result name="report" type="redirectAction">
                                  <param name="namespace">/report</param>
                                  <param name="actionName">perimetersReport</param>
                              </result>
                          </action>
                  
                      </package>
                  
                      <package name="report" extends="default" namespace="/report">
                          <action name="*Action"
                              class="com.omb.controller.report.MyAction"
                              method="{1}">
                              <result name="succes" type="tiles">succesTile</result>
                          </action>
                      </package>
                  </struts>
                  

                  推荐答案

                  我应该怎么做才能选择所有值?

                  what should I do for get all value selected ?

                  您应该制作一个 select 标签来接受多个选项.这是通过 struts select 标签中的 multiple=true" 完成的.然后你的拦截器堆栈不完整,因为 multiselect 拦截器 丢失.您应该在 添加到您的拦截器堆栈中upload-interceptor.html" rel="nofollow noreferrer">fileUpload 拦截器 参考.

                  You should make a select tag to accept multiple options. This is done via multiple="true" in struts select tag. Then you interceptor stack is incomplete because multiselect interceptor is missing. You should add <interceptor-ref name="multiselect"/> to your interceptor stack after fileUpload interceptor reference.

                  这篇关于如何从 Struts 2 中的选择标记映射多个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:没有为动作和结果定义结果 下一篇:在 Weblogic 12c 启动期间出现的来自 Struts 的额外信息消息

                  相关文章

                1. <legend id='JIrZb'><style id='JIrZb'><dir id='JIrZb'><q id='JIrZb'></q></dir></style></legend>
                2. <tfoot id='JIrZb'></tfoot>

                      <small id='JIrZb'></small><noframes id='JIrZb'>

                        <bdo id='JIrZb'></bdo><ul id='JIrZb'></ul>
                    1. <i id='JIrZb'><tr id='JIrZb'><dt id='JIrZb'><q id='JIrZb'><span id='JIrZb'><b id='JIrZb'><form id='JIrZb'><ins id='JIrZb'></ins><ul id='JIrZb'></ul><sub id='JIrZb'></sub></form><legend id='JIrZb'></legend><bdo id='JIrZb'><pre id='JIrZb'><center id='JIrZb'></center></pre></bdo></b><th id='JIrZb'></th></span></q></dt></tr></i><div id='JIrZb'><tfoot id='JIrZb'></tfoot><dl id='JIrZb'><fieldset id='JIrZb'></fieldset></dl></div>