zoukankan      html  css  js  c++  java
  • Servlet(11)—客户端跳转和服务端跳转

    客户端跳转:

    1、链接跳转:< a href=””>< /a >

    2、表单提交< form>< /form>

    3、Response.sendRedirect(“3.jsp”);

    4、< mata http-equiv=”refresh”, content=”3;2.jsp”/ >

    5、response.setHeader(“refresh”,” 3;2.jsp”);

    6、客户端跳转“/”代表站点根路径webapp,即http://localhost:8080

    服务端跳转:
    1、< jsp:forward page=””/>

    2、pageContext.forward();

    3、 request.getRequestDispatcher(“1.jsp”).forward(request,response);

    4、服务器端跳转“/”代表web应用根路径,即:http://localhost:8080/Demo/

    注意:使用时如果要使用相对路径时,只有在客户端跳转时加上${pageContext.request.contextPath },该值为web应用的名称。

    另外
    http://localhost:8080/Demo09_Filter/demo6/articles.jsp
    request.getContextPath():表示web应用的名称,如/Demo09_Filter
    request.getServletPath():表示的是url地址栏中web应用名称之后的地址/demo6/articles.jsp

  • 相关阅读:
    poj 2388
    BUAA 1489
    poj 2524
    poj 2109
    poj 2503 Babelfish
    poj All in All
    poj 1611 The Suspects
    poj 2299
    poj 1328
    hdu 1008 Elevator
  • 原文地址:https://www.cnblogs.com/tengpengfei/p/10453984.html
Copyright © 2011-2022 走看看