您的位置:首页 > 编程语言 > PHP开发

接收全部参数getParameterNames()

2016-10-01 01:20 225 查看
html:

<!DOCTYPE html>

<html>

<head>

<title>接收全部参数</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">

<meta name="description" content="this is my page">

<meta name="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

</head>

<body>
<form action="request_demo3.jsp" method="post">
姓名:<input type="text" name="uname"><br> 
性别:<input type="radio" name="sex" value="男" checked>男 
<input type="radio" name="sex" value="女">女<br>
城市:<select name="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option>
<option value="广州">广州</option>
<option value="西安">西安</option>
</select><br>
爱好:<input type="checkbox" name="inst" value="c语言">c语言  
<input type="checkbox" name="inst" value="c++语言">c++语言 
<input type="checkbox" name="inst" value="c#语言">c#语言  
<input type="checkbox" name="inst" value="object-c语言">object-c语言 
    <input type="checkbox" name="inst" value="ASP.NET语言">ASP.NET语言<br>
自我介绍:<textarea cols="30" rows="3" name="note"></textarea><br> 
  <input type="submit" value="提交"><br />
  <input type="reset" value="重置"><br />
</form>

</body>

</html>

jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'request_demo3.jsp' starting page</title>

    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>

  

  <body>

  <%

  request.setCharacterEncoding("UTF-8");

   %>

   <center>

   <table border="1">

   <tr>

   <td>参数名称</td>

   <td>参数内容</td>

   </tr>

   <%

    Enumeration<String> enu=request.getParameterNames();

    while(enu.hasMoreElements())

    {

      String paramName=enu.nextElement();

    %>

    <tr>

    <td><%=paramName%></td>

    <td>

    <%

     if(paramName.startsWith("**")){

     String paramValue[]=request.getParameterValues(paramName);

     for(int i=0;i<paramValue.length;i++)

     {

     %>

     <%=paramValue[i]%>

     <%

     }

     }

     else

     {

      String paravalue=request.getParameter(paramName);

      %>

      <%=paravalue%>

      <%

      }

       %>

       </td>

       </tr>

    <%

    }

     %>

   </table>

   </center>

  </body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐