zoukankan      html  css  js  c++  java
  • jsp select multiple

    //File: index.html
    <HTML>
        <HEAD>
            <TITLE>Submitting Multiple Selection Select Controls</TITLE>
        </HEAD>
     
        <BODY>
            <H1>Submitting Multiple Selection Select Controls<H1>
            <FORM ACTION="formAction.jsp" METHOD="POST">
                <SELECT NAME="select1" SIZE="5" MULTIPLE>
                    <OPTION>Option 1</OPTION>
                    <OPTION SELECTED>Option 2</OPTION>
                    <OPTION>Option 3</OPTION>
                    <OPTION>Option 4</OPTION>
                    <OPTION>Option 5</OPTION>
               </SELECT>
               <BR>
               <INPUT TYPE="SUBMIT" VALUE="Submit">
           </FORM>
        </BODY>
    </HTML>

    //File: formAction.jsp
    <HTML>
        <HEAD>
            <TITLE>Reading Multiple Selection Select Controls</TITLE>
        </HEAD>

        <BODY>
            <H1>Reading Multiple Selection Select Controls</H1>
            You selected:
            <BR>
            <% String[] items = request.getParameterValues("select1");
            for(int loopIndex = 0; loopIndex < items.length; loopIndex++){
                out.println(items[loopIndex] + "<BR>");
            }
            %>
        </BODY>
    </HTML>

    注意select1中必须有选中的项,否则不会传递到新的jsp页面。

    REF:

    http://www.devmanuals.com/tutorials/java/jsp/multipleSelectOption.html

    http://www.java2s.com/Code/Java/JSP/SubmittingMultipleSelectionSelectControls.htm

    http://stackoverflow.com/questions/2407945/how-to-get-multiple-selected-values-from-select-box-in-jsp

    http://www.xue163.com/165/6/1654775.html

    http://blog.csdn.net/overmind/article/details/670109

  • 相关阅读:
    软件架构自学笔记-- 软件架构师是如何工作的
    软件架构自学笔记---架构概述
    HDFS Shell命令操作与java代码操作
    定义maven的项目结构
    企业级Spring应用的搭建
    HDFS与java API应用
    Azure Database for MySQL 报 Please specify SSL options and retry.
    seata-server安装、运行
    sentinel-dashboard安装、运行(ubuntu)
    nacos-server集群 安装、运行(ubuntu)
  • 原文地址:https://www.cnblogs.com/emanlee/p/4515381.html
Copyright © 2011-2022 走看看