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. (学)解决VMware Taking ownership of this virtual machine failed

    原文:http://blog.csdn.net/fisher_jiang/article/details/6992588背景: 一次crash可能会造成虚拟机锁死的情况发生现象:点击take owne ...

  2. javascript学习之通过class获取元素

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  3. Lua字符串库

    1. 基础字符串函数:    字符串库中有一些函数非常简单,如:    1). string.len(s) 返回字符串s的长度:    2). string.rep(s,n) 返回字符串s重复n次的结 ...

  4. CI框架入门2

    文件目录与布局 1.user_guide    用户手册,可删 2.readme.rst    说明,可删 3.license.txt     证书,可删 4..gitignore composer. ...

  5. linux软件包管理(下)

    在vi配置文件的编写的时候我们发现#并不能注释掉一行的信息 那什么才是linux标准的注释信息呢 查看软件对应的软件包命令 rpm –ap| grep vim 大多example是需要的事例文档  双 ...

  6. MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作(转载)

    本文转载自:http://www.cnblogs.com/jpf-java/p/6013540.html 上一篇博文MyBatis学习总结(一)--MyBatis快速入门中我们讲了如何使用Mybati ...

  7. org.springframework.web.servlet.DispatcherServlet noHandlerFound

    1 请求URL: http://localhost:8080/mvc/rojas 2 control  RequestMapping  : @RequestMapping(value="xx ...

  8. redis3.2 Jedis java操作

    package com.util; import java.util.HashSet; import java.util.List; import java.util.Map; import java ...

  9. Python 2.7 - CentOS 7 - ImportError: No module named Tkinter

    It's simple. sudo yum -y install tkinter Just want to say, "I'm back".

  10. 动态SQL语句之sp_executesql的使用

    sp_executesql,sql2005中引入的新的系统存储过程,也是用来处理动态sql的, 如: exec sp_executesql @sql, N'@item_name nvarchar(10 ...