jsp:request.getParameterValues()的两种遍历实现

来源:互联网 发布:淘宝卖家图片详情模板 编辑:程序博客网 时间:2024/04/29 05:29

jsp:request.getParameterValues()的两种遍历实现

  1. web页面

      <form action="hello.jsp">   <input type="checkbox" name="hello" value="aa" >a   <input type="checkbox" name="hello" value="bb" >b   <input type="checkbox" name="hello" value="cc" >c   <input type="submit" name="b1" value="提交"/>   </form>

    web页面

  2. jsp页面

    遍历方法 一

    <%        String[] strs = request.getParameterValues("hello");        if (strs != null) {            int size = java.lang.reflect.Array.getLength(strs);            for (int i = 0; i < size; i++) {                out.println(strs[i] + "<br>");            }        }    %>

    遍历方法 二

    <%        String[] strs2 = request.getParameterValues("hello");        for (String s : strs2) {            out.println(s + "<br>");        }    %>

    jsp结果

0 0
原创粉丝点击