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()区别如下: ...
随机推荐
- PAT 1001 害死人不偿命的(3n+1)猜想 (15)(C++&JAVA&Python)
1001 害死人不偿命的(3n+1)猜想 (15)(15 分) 卡拉兹(Callatz)猜想: 对任何一个自然数n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把(3n+1)砍掉一半.这样一直反 ...
- idea 高级调试技巧
两年前写过一篇关于idea的高级用法,今天再来一篇关于调试方面的技巧讲解: 一.条件断点 循环中经常用到这个技巧,比如:遍历1个大List的过程中,想让断点停在某个特定值. 参考上图,在断点的位置,右 ...
- BZOJ 1791: [IOI2008]Island 岛屿 - 基环树
传送门 题解 题意 = 找出无向基环树森林的每颗基环树的直径. 我们首先需要找到每颗基环树的环, 但是因为是无向图,用tarjan找环, 加个手工栈, 我也是看了dalao的博客才知道tarjan找无 ...
- 常用到的photoshop实用设计功能都在这了!
常用到的photoshop实用设计功能都在这了!赶快收藏学起来,需转不谢~ 编辑:千锋UI设计
- Statement、PreparedStatement、CallableStatement的区别
此三个接口的声明如下: public interface Statement extends Wrapper, AutoCloseable public interface PreparedState ...
- C++11与Unicode及使用标准库进行UTF-8、UTF-16、UCS2、UCS4/UTF-32编码转换
zt https://blog.poxiao.me/p/unicode-character-encoding-conversion-in-cpp11/ Unicode Unicode是计算机领域的一项 ...
- js中 xpath 使用
一.使用: 非IE浏览器,使用 document.evaluate var result = document.evaluate("//a[@href]", document, n ...
- Vue 汇总
1.右键菜单(防止默认行为) @contextmenu.native.prevent="rightClick()"
- 2017/2/14springmvc基础学习
一:核心类与接口 DispatcherServlet :前置控制器 ,HandlerMapping:请求处理接口 HandlerMapping:接口实现类 ViewResolver接口的实现类Url ...
- 通用Mapper
原理是:拦截器 1.假设:使用MyBatis只需要定义Mapper接口,无需编写Mapper.xml文件 如果实现无需编写Mapper.xml文件,我们必须要实现动态拼接SQL 如何实现动态拼接SQL ...