forward请求转发,param参数传递以及request.getParameter图文讲解
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!doctype html>
<html>
<head>
<title>login</title>
<meta http-equiv="content-type" comtent="text/html;charset=utf-8"/>
</head>
<body>
<h1><font color="red">欢迎</font></h1>
<form action="loginCheck.jsp" method="get">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="name" value=
"<%=request.getParameter("name")%>" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td><input type="submit" value="登录"/></td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!doctype html>
<html>
<head>
<title>loginCheck</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<%
String name = request.getParameter("name");
String pass = request.getParameter("password");
%>
<%
//if(name.equals("QQ") && password.equals("123"))
if("QQ".equals(name) && "123".equals(pass))
{
%>
<%--forward作用是转发客户端的请求 --%>
<jsp:forward page="success.jsp">
<jsp:param name="user" value="<%=name %>"/>
</jsp:forward>
<% }
else
%>
<%{
%> <jsp:forward page="login.jsp">
<jsp:param name="name" value="<%=name %>"/>
</jsp:forward>
<%}
%> </body>
</html>
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!doctype>
<html>
<head>
<title>success</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
</head>
<body>
<h2>登录成功</h2>
<hr/>
欢迎<%=request.getParameter("user")%>
</body>
</html>

forward请求转发,param参数传递以及request.getParameter图文讲解的更多相关文章
- Spring MVC中forward请求转发2种方式(带参数)
Spring MVC中forward请求转发2种方式(带参数) http://www.51gjie.com/javaweb/956.html
- ajax post 请求 ,java端使用 request.getParameter 获取不到数据问题
js端 $.ajax({ type:'POST', data:{a:1}, url:_this.apiUrl+url, dataType:'json',//使用jsonp方式请求 contentTyp ...
- request 请求转发
package request; import java.io.IOException;import javax.servlet.ServletException;import javax.servl ...
- request的请求转发
1.请求转发和重定向的区别 重定向: 请求转发: 可以看出,请求转发只需要发起一次请求,与重定向不同,请求转发发生在服务器内部.请求转发后浏览器的地址不会改变. 2.request请求转发 需要建立两 ...
- Servlet(10)—请求转发和请求重定向
请求转发与请求重定向 ①区别: 本质区别:请求转发只发出一次请求,请求重定向则发出两次请求. 请求转发:地址栏是初次发出请求的地址在最终的Servlet中,request对象和中转的那个request ...
- request.getAttribute() 和 request.getParameter() 有何区别?
HttpServletRequest类既有getAttribute()方法,也由getParameter()方法,这两个方法有以下区别: (1)HttpServletRequest类有setAttri ...
- 〖转〗request.getparameter()和request.getAttribute()的区别
getAttribute表示从request范围取得设置的属性,必须要先setAttribute设置属性,才能通过getAttribute来取得,设置与取得的为Object对象类型 getParame ...
- request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- request.getParameter()与request.setAttribute()的区别 (转载)
request.getParameter()与request.setAttribute()的区别 request.getParameter(),request.setAttribute()区别如下: ...
随机推荐
- do_something方法解析
/** * 运行任务 * @param $interval * @return bool */ static public function do_something($interval) { //是 ...
- IDEA 的 Edit 设置
1.设置鼠标悬浮提示 General -- Show quick documentation on mouse move 2.自动导包 3.设置显示行号和方法的间隔符 4.忽略大小写 4.设置取消单 ...
- spring读取properties的几种方式
参考链接:http://www.cnblogs.com/zxf330301/p/6184139.html
- BZOJ1079或洛谷2476 [SCOI2008]着色方案
一道记忆化搜索 BZOJ原题链接 洛谷原题链接 发现对于能涂木块数量一样的颜色在本质上是一样的,所以可以直接压在一个状态,而这题的数据很小,直接暴力开\(6\)维. 定义\(f[a][b][c][d] ...
- js的日期格式判断
var reg = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/; var str = (new Date).toLocaleString() ...
- 使用UIkit的uk-form-icon后input框无法输入的问题
相关版本UIkit2.27.5 uikit.min.css默认使用uk-form-icon的属性pointer-events: none:因此表框无法点击. <style type=text/c ...
- Socket 学习笔记 01 常用函数
常用方法 创建套接字: socket() 绑定本机端口: bind() 建立连接: connect(),accept() 侦听端口: listen() 数据传输: send() ...
- Viewer.js 是一款强大的 jQuery 图像浏览插件。
https://blog.csdn.net/qq_29132907/article/details/80136023 一.效果图 二.代码<!DOCTYPE html><html ...
- jquery选择树:CheckTree 插件
在做权限等提交的时候,需要用到选择树.比较了很多插件如:easyUI 树,ztree等等.本来决定自己写,但是到最后还是发现了checkTree这个插件.省了很多事情. 但是在引用过程中还是出现了一些 ...
- ajax +jsp+iframe无刷新上传文件[转]
http://hi.baidu.com/zj360202/blog/item/f23e3711f929c774cb80c475.html ajax jsp 无刷新上传文件 2009-10-26 16: ...