1、HTML:

①、

<head>
<!-- 以下方式只是刷新不跳转到其他页面 -->
<meta http-equiv="refresh" content="10">
<!-- 以下方式定时转到其他页面 -->
<meta http-equiv="refresh" content="5;url=hello.html">
</head>

2、javascript:

①、window.location.href方式

<script language="javascript" type="text/javascript">
// 以下方式直接跳转
window.location.href='hello.html';
// 以下方式定时跳转
setTimeout("javascript:location.href='hello.html'", 5000);
</script>

②、window.navigate方式跳转

<script language="javascript">
window.navigate("target.aspx");
</script>

③、window.loction.replace方式

<script language="javascript">
window.location.replace("target.aspx");
</script>

④、self.location方式

<script language="JavaScript">
self.location='target.aspx';
</script>

⑤、top.location方式

<script language="javascript">
top.location='target.aspx';
</script>

⑥、返回方式

<script language="javascript">
alert("返回");
window.history.back(-1);
</script>

PS:Javascript刷新页面的几种方法: 
 history.go(0) 
 location.reload() 
 location=location 
 location.assign(location) 
 document.execCommand('Refresh') 
 window.navigate(location) 
 location.replace(location) 
 document.URL=location.href

3、Java类(servlet):

①、response.sendRedirect("/a.jsp");

  页面的路径是相对路径。sendRedirect可以将页面跳转到任何页面,不一定局限于本web应用中,如:

response.sendRedirect("http://www.jb51.net");

  跳转后浏览器地址栏变化。

  这种方式要传值出去的话,只能在url中带parameter或者放在session中,无法使用request.setAttribute来传递。

②、RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");

  dispatcher .forward(request, response);

  页面的路径是相对路径。forward方式只能跳转到本web应用中的页面上。

  跳转后浏览器地址栏不会变化。

  跳转到同级目录下的页面。

  使用这种方式跳转,传值可以使用三种方法:url中带parameter,session,request.setAttribute

4、JSP:

①、response.sendRedirect();

  同上。

②、response.setHeader("Location","");

  此语句前不允许有out.flush(),如果有,页面不会跳转。

  跳转后浏览器地址栏变化

  此语句后面的语句执行完成后才会跳转

URL跳转的几种方式的更多相关文章

  1. js实现页面跳转的两种方式

      CreateTime--2017年8月24日08:13:52Author:Marydon js实现页面跳转的两种方式 方式一: window.location.href = url 说明:我们常用 ...

  2. thinkphp 3.2.3 入门示例2(URL传参数的几种方式)

    原文:thinkphp中URL传参数的几种方式 在thinkphp中,url传参合asp.net中原理类似,下面就单个参数和多个参数传递方式进行一个简单讲解 1.传单个参数 单个参数这种比较简单,例如 ...

  3. vue中通过路由跳转的三种方式

    原文:https://blog.csdn.net/qq_40072782/article/details/82533477 router-view 实现路由内容的地方,引入组件时写到需要引入的地方需要 ...

  4. springmvc url处理映射的三种方式:

    一.SpringMVC简介 SpringMVC是一种基于Spring实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,使用了MVC架构模式的思想,将web层进行职责解耦,并管理应用所需对象 ...

  5. web页面跳转的几种方式

    可用客户端触发或服务端触发的方式来实现页面跳转. 客户端触发 方式一:使用Javascript 利用window.location对象的href属性.assign()方法或replace()方法来实现 ...

  6. PHP-网页跳转的几种方式

    本文总结了跳转到指定网页的几种方式. 1.利用PHP的header函数Location响应头, header是用来向浏览器返回HTTP响应头(详细请看HTTP协议详解) <?php header ...

  7. JSP实现界面的自动跳转的几种方式

    下面来谈一谈在jsp中实现的几种界面自动跳转的方法. 使用JavaScript脚本 <html> <script language=javascript> function o ...

  8. php实现页面跳转的几种方式

    PHP中实现页面跳转有一下几种方式,看了几个人写的不是很条理,自己整理一下 在PHP脚本代码中实现 <?php header("location:url地址") ?> ...

  9. PHP 页面跳转的三种方式

    第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $re ...

随机推荐

  1. 在list_*页面显示出一级栏目下的所有二级栏目

    <ul class="nav nav-pills nav-stacked"> {dede:channelartlist typeid='1,1'} <div cl ...

  2. Ubuntu14.10下安装JDK 8

    方法一1、下载 JDK 8http://www.oracle.com/technetwork/java/javasebusiness/downloads/此处由于我的系统是Ubuntu14.10 64 ...

  3. 【WPF】绑定数据

    WPF绑定数据 模型类(继承 INotifyPropertyChanged,实现属性的变更通知)

  4. 基于jquery上的轻量级《数据模板解析》插件

    1.先上一个栗子. <!doctype html> <html lang="en"> <head> <meta charset=" ...

  5. jQuery文本段落展开和折叠效果

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...

  6. jsp标签<c:forEach>取出传递参数注意

    运行书里的代码,其中servlet可以通过以下两个方式向jsp传参数: 1.         request.getSession().setAttribute("productList&q ...

  7. java swing文件内容检索工具

    Java相关技术 - 文件内容检索工具 拿到一个几百M甚至上G的project让你去学习 有时候你会想知道某个关键词是在哪个文件里 比如:spring MVC配置的@RequestMapping,你从 ...

  8. 如何在spring容器开始后,和销毁前,执行一些操作

    转:参考文档:资料链接

  9. CSP -- 运营商内容劫持(广告)的终结者

    缘由 我们公司最近手机端H5 经常受到商户和用户的投诉,说有广告并且导致不能正常进行操作,我们商户自己当然不会加广告了,但是商户和用户可不管这些了,就认为是我们的问题 探索发现根本 目前我们用的很多浏 ...

  10. 判断浏览器类型用 document.documentMode方式,

    if ( document.documentMode && document.documentMode < 9 ){ document.write( '<script sr ...