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. Python获取当前日期及时间

    import time def GetNowTime(): return time.strftime("%Y%m%d%H%M%S",time.localtime(time.time ...

  2. asdfsadfs

    # -*- coding:utf8 -*- import os import jieba.posseg as pseg # -*- coding:utf8 -*- import os  def spl ...

  3. 【emWin】例程六:设置颜色

    实验指导书及代码包下载: 链接:http://pan.baidu.com/s/1eSidREy 密码:ru3c 实验现象:

  4. 双十二前夕爆京东12G数据泄露的真相是什么

    今天早上手机上推送出京东12g数据泄漏的消息,随即搜了下网上的相关新闻,感觉舆论又一次的干了一件惊天地的事情,到底京东的哪所谓的12G的用户信息数据有没有泄漏?舆论为什么齐刷刷的在12月11日突然间爆 ...

  5. asp.net mvc 过滤器

    https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters#ordering 1. 对于应用在 Action 上的多个行为 ...

  6. Thinkphp 验证码

    一.生成验证码 $Verify = new \Think\Verify(); $Verify->entry(); 生成的验证码信息会保存到session中,里面包含数据有: array('ver ...

  7. C++ 从一组数据中按概率选择一个

    #include <stdio.h> #include <stdint.h> #include <ctime> #include <vector> #i ...

  8. 升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    系统升级到macOS 10.12后启动mysql后,在终端输入mysql 报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' ...

  9. WinServer2003 文件夹共享 方法设置

    文件夹设置: 5.假设我们在E盘有一个wmpub文件夹要设置在网络中共享,让大家都可以看到,首先我们右键点击WMPUB文件夹[共享和安全],弹出对话框,选择[共享此文件夹],点击[权限],弹出的对话框 ...

  10. ceph network introduce

    网络结构 Ceph 使用以太网连接内部各存储节点以及连接 client 和集群.Ceph 推荐使用两个网络: 前端(北向)网络( a public (front-side) network):连接客户 ...