zoukankan      html  css  js  c++  java
  • JSP 页面重定向


    JSP 页面重定向


    当需要将文档移动到一个新的位置时,就需要使用JSP重定向了。

    最简单的重定向方式就是使用response对象的sendRedirect()方法。这个方法的签名如下:

    public void response.sendRedirect(String location)
    throws IOException

    这个方法将状态码和新的页面位置作为响应发回给浏览器。您也可以使用setStatus()和setHeader()方法来得到同样的效果:


    ....
    String site = "http://www.ziqiangxuetang.com" ;
    response.setStatus(response.SC_MOVED_TEMPORARILY);
    response.setHeader("Location", site);
    ....

    JSP如何进行页面重定向:

    <%@ page import="java.io.*,java.util.*" %>
    <html>
    <head>
    <title>Page Redirection</title>
    </head>
    <body>
    <center>
    <h1>Page Redirection</h1>
    </center>
    <%
    // 重定向到新地址
    String site = new String("http://www.ziqiangxuetang.com");
    response.setStatus(response.SC_MOVED_TEMPORARILY);
    response.setHeader("Location", site);
    %>
    </body>
    </html>

  • 相关阅读:
    C++官方文档-静态成员
    C++官方文档-this
    C++官方文档-运算符重载
    springboot-dokcer
    HDU 1073
    HDU 1070
    UVa 213
    HDU 1150
    POJ 1274
    POJ 2594
  • 原文地址:https://www.cnblogs.com/Alanf/p/10212932.html
Copyright © 2011-2022 走看看