java中获取网页的get或post数据的方法有以下三种:getParameter(name); 获取单参数的方法。getParameterValues(name); 获取多参数值的方法,如复选框的值,返回一个数组getParameterNa ...
java中获取网页的get或post数据的方法有以下三种:
- getParameter(name); 获取单参数的方法。
- getParameterValues(name); 获取多参数值的方法,如复选框的值,返回一个数组
- getParameterNames(name); 获取request中的所有参数,返回一个枚举类型
本次的实例主要是关于getParameter(), getParameterValues()的。
实例:
HTML:
1 <!DOCTYPE html> 2 <!--为了简洁,不写注释啦--> 3 <html> 4 <head> 5 <meta charset="utf-8" /> 6 <title>entity</title> 7 <meta name="description" content="this is description" /> 8 <meta name="keywords" content="keyword1,keyword2,keyword3" /> 9 </head>10 <body>11 <h1>Get Form Information</h1>12 <hr/>13 <form action="servlet/Test" method="post">14 <table><tbody>15 <tr>16 <td>姓名:</td>17 <td><input type="text" name="username" /></td>18 </tr>19 <tr>20 <td>爱好:</td>21 <td><input type="checkbox" name="hobby" value="NBA" />NBA <input type="checkbox" name="hobby" value="旅游" 22 23 />旅游 <input type="checkbox" name="hobby" value="看书" />看书24 </td>25 </tr>26 <tr>27 <td><input type="submit" value="提交数据"/></td>28 <td><input type="reset" value="重置数据" /></td>29 </tr>30 <tr></tr>31 </tbody></table>32 </form>33 </body>34 </html>
原标题:Servlet之获取前端的数据
关键词:前端
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。