• 关于servlet中重定向、转发的地址问题


      先写一个正斜杠"/",再判断是服务器使用该地址还是网站使用该地址。

      访问网络资源用/,访问硬盘资源用。

      例如:

    转发:      request.getRequestDispatcher("/fenYe").forward(request, response);    ①

    重定向:    response.sendRedirect("/dayo6/1.html");                                               ②

    获取真实URL:     this.getServletContext().getRealPath("/1.jsp");         ①

    作为流:                this.getServletContxt().getResourceAsStream("/1.jsp");             ①

    html中:

      <a href="/day06/1.html"></a>         ②

           <form action="/day06/1.html">   ②

     上面①代表服务器使用,②代表网站使用。day06为项目名字。

    JSP中获取工程名字EL表达式:

      ${pageContext.request.contextPath}

  • 相关阅读:
    嵌入式和就业(转)
    [转] 电子技术·笔记1(9月份)
    ERP系统
    Win7 启动修复
    A1pass大大对黑客学习的建议
    你凭什么能过上你想要的生活?
    Hacker需要掌握的基础
    Hacker学习发展流程图
    硬盘SMART参数解释
    u盘的一些理解
  • 原文地址:https://www.cnblogs.com/qlqwjy/p/7429510.html
Copyright © 2020-2023  润新知