几种常用页面的跳转

JSP 跳转

1、转发:request.getRequestDispatcher(".jsp").forward(request,response);
2、重定向:response.sendRedirect("success.jsp");
转发,前后页面共享一个request,重定向是重新定向  前后页面不是一个request
3、<jsp:forward page="URL"/>

js页面的跳转方式:

        window.location.href="URL";

html页面跳转

1、html中使用meta中跳转,通过meta可以设置跳转时间和页面

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

2.a标签直接跳转

<a href="http://baidu.com">百度一下</a>

3.表单与按钮的跳转

<input type="button" value="我是一个按钮" onclick="javascrtpt:window.location.href='http://blog.sina.com.cn/mleavs'">

方法二:触发一个函数跳转

<script>
function jump(){
window.location.href="http://blog.sina.com.cn/mleavs";
}
</script>

<input type="button" value="我是一个按钮" onclick=javascrtpt:jump()>

方法三:a标签的超链接可以直接嵌套一个button

<a href="https://www.baidu.com/">
<button>点我跳转到度娘!</button>
</a>

方法四:表单的action定向提交跳转

<form action="xx.html" method="post">
<input type="bottom" value="按钮">
</from>





原文地址:https://www.cnblogs.com/yangj-Blog/p/12985275.html