js判断字符串是否包含某个字符串_jsp sendRedirect()方法进行跳转详解

更新时间:2017-04-15    来源:js教程    手机版     字体:

【www.bbyears.com--js教程】

直接跳转到hello.html页面 response_demo03.jsp

 

 代码如下

<%@ page language="java" contentType="text/html" pageEncoding="GBK"%> 

 

 

测试 

 

 

<% 

 response.sendRedirect("hello.html"); 

%> 

 

这种跳转属于客户端跳转

属于服务端跳转,地址不会发生改变,可以将request属性保存到跳转页
response.sendRedirect()属于客户端跳转,地址会发生改变,不可以将request属性保存到跳转页
还有一个区别就是:服务端跳转会立刻跳转,而客户端跳转在整个页面执行完后才进行跳转

服务器端跳转response_demo04.jsp

 代码如下

<%@ page language="java" contentType="text/html" pageEncoding="GBK"%> 

 

 

测试 

 

 

<% 

 System.out.println("----------forward跳转之前的-------------"); 

%> 

 

<% 

 System.out.println("----------forward跳转之后的-------------"); 

%> 

 


 

显示结果:hello
但tomcat服务器后台显示----------forward跳转之前的-------------

 代码如下

客户端跳转 response_demo05.jsp

view sourceprint?<%@ page language="java" contentType="text/html" pageEncoding="GBK"%> 

 

 

测试 

 

 

<% 

 System.out.println("----------response跳转之前-------------"); 

%> 

<% 

 response.sendRedirect("hello.html"); 

%> 

<% 

 System.out.println("----------response跳转之后------------"); 

%> 

 

tomcat服务器后台显示----------response跳转之前-------------
     ----------response跳转之后-------------

本文来源:http://www.bbyears.com/wangyezhizuo/31936.html

猜你感兴趣

热门标签

更多>>

本类排行