首页 技术 正文
技术 2022年11月16日
0 收藏 818 点赞 4,818 浏览 811 个字

JAVA-JSP内置对象之request获得参数的参数值(一个值)

相关资料:
《21天学通Java Web开发》

获得参数的参数值(一个值)

RequestForm3.jsp

 <%@ page language="java" contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>表单</title>
</head>
<body>
<form action="RequestDemo3.jsp" method="post">
用户名:<input type= "text" name="username"/><br>
用户密码:<input type= "password" name="userpassword"/>
<input type="submit" value="提交">
</form>
</body>
</html>

RequestDemo3.jsp

 <%@ page language="java" contentType="text/html;charset=gb2312" import="java.util.*" %>
<html>
<head>
<title>使用request对象获得所有参数的参数值</title>
</head>
<body>
<%-- 通过request对象的getParameterNames --%>
<%
Enumeration<String> e = request.getParameterNames();//获得所有的参数名称
while(e.hasMoreElements()){ //遍历Enumeration
String str = (String)e.nextElement(); //取出下一个元素值
String strRequest = request.getParameter(str); //取得相应参数的参数值
out.println(str+"参数值为:"+strRequest+"<br>");//打印输出参数名称和参数值
}
%>
</body>
</html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,956
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,480
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,327
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,110
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,741
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,776