Servlet-重定向
来源:互联网 发布:iscroll.js 官网下载 编辑:程序博客网 时间:2024/05/20 15:39
1、第一个Servlet
/** * @author CSDN_LQR * @TODO 重定向 */public class ServletDemo6 extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("A:我要钱"); System.out.println("B:我没有,跟C拿");// response.setStatus(302);// response.setHeader("location", "demo7"); //这一句相当于上述两句 response.sendRedirect("demo7"); System.out.println("A:好,我就去"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); }}
/**
* @author CSDN_LQR
* @TODO 测试重定向
*/
public class ServletDemo7 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("C:我有的是钱,100万拿去,随便花");}public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response);}
}
注意:打印顺序如下:
A:我要钱
B:我没有,跟C拿
A:好,我就去
C:我有的是钱,100万拿去,随便花
“`
可见,重定向并不是立刻跳转,而是先执行整个Servlet请求后,浏览器再根据响应头再进行跳转动作。
0 0
- SERVLET中的重定向
- Servlet 重定向问题
- servlet重定向
- servlet重定向
- servlet重定向问题
- servlet重定向
- Servlet 重定向原理
- 在servlet重定向
- Servlet中的重定向
- Servlet重定向
- servlet备忘[重定向]
- Servlet-重定向
- Servlet 网页重定向
- Servlet请求重定向
- Servlet 重定向原理
- Servlet 网页重定向
- JSP/Servlet的重定向
- jsp和servlet重定向
- iOS 标记方法或属性过期
- 黑白棋经典残局(2)
- Codeforces Intel Code Challenge Final Round (Oct/08/2016)
- [kuangbin带你飞]专题一 简单搜索 Pots : BFS
- Leetcode 82, remove duplicates from sorted list 2
- Servlet-重定向
- 解决linux删除文件后空间没有释放问题
- 如何理解Python装饰器?
- jquery datagrid 的一些用法
- 日常训练20161014 跟踪
- unity C# xml创建,获取,修改,删除(android同样适用)
- ubuntu14.04配置安装pycharm professional
- 解决UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 108: ordinal not in range(128
- 八大排序--基数排序