如何从JSP的选择框中获取多个选择的值? [英] How to get multiple selected values from select box in JSP?

查看:101
本文介绍了如何从JSP的选择框中获取多个选择的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html表单,该表单具有一个选择列表框,您可以从中选择多个值,因为其multiple属性设置为 multiple .考虑表格方法是获取方法.表单的html代码如下.

I have a html form which have a select list box from which you can select multiple values because its multiple property is set to multiple. Consider form method is get method. The html code for form is as follows.

<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="get" action="display.jsp">
  <table width="300" border="1">
    <tr>
      <td><label>Multiple Selection </label>&nbsp;</td>
      <td><select name="select2" size="3" multiple="multiple" tabindex="1">
        <option value="11">eleven</option>
        <option value="12">twelve</option>
        <option value="13">thirette</option>
        <option value="14">fourteen</option>
        <option value="15">fifteen</option>
        <option value="16">sixteen</option>
        <option value="17">seventeen</option>
        <option value="18">eighteen</option>
        <option value="19">nineteen</option>
        <option value="20">twenty</option>
      </select>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Submit" tabindex="2" /></td>
    </tr>
  </table>
</form>
</body>
</html>

我想在display.jsp页面的选择列表框中显示选定的值.那么如何在display.jsp页面上访问选定的值.

I want to display the selected values in select list box on display.jsp page. So how the selected values are accessed on display.jsp page.

推荐答案

返回所有已提交值的数组.

request.getParameterValues("select2") returns an array of all submitted values.

这篇关于如何从JSP的选择框中获取多个选择的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆