zoukankan      html  css  js  c++  java
  • Web 编程中路径问题

    1. web.xml 中 <url-pattern> 路径(即 Servlet 路径)
      • 要么以 "*" 开头, 要么以 "/" 开头.
    2. 转发和包含路径(服务器端路径)
      • 以 "/" 开头, 相对当前项目路径, 例如: http://localhost:8080/项目名/ (建议使用)
      • 不以 "/" 开头, 相对当前 Servlet 路径.
    3. 重定向路径(客户端路径)
      • 以 "/" 开头, 相对当前主机, 例如 "http://localhost:8080/", 所以需要自己
        手动添加项目名.
    4. 页面中超链接和表单路径
      • 与重定向相同, 都是客户端路径, 需要添加项目名.
    5. ServletContext 获取资源路径
      • 相对当前项目目录, 即 WEB-Content 目录
    6. ClassLoader 获取资源路径, 不能以 "/" 开头
      • 相对 classes 目录
    7. Class 获取资源路径
      • 以 "/" 开头, 相对 classes 目录
      • 不以 "/" 开头, 相对当前 .class 文件所在目录

    参考资料:

  • 相关阅读:
    Reverse Linked List
    Sqrt(x)
    Convert Sorted Array to Binary Search Tree
    Remove Linked List Elements
    Happy Number
    Length of Last Word
    Pow(x, n)
    Rotate Image
    Permutations
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/linkworld/p/7588491.html
Copyright © 2011-2022 走看看