web項目路徑問題

來源:互聯網
上載者:User

標籤:

路徑
    相對路徑
        URL中第一個字元不為“/”
        request.getRequestDispatcher("b");
        相對於該代碼所在的位置,指的是java檔案的位置。
    
    絕對路徑
        URL中第一個字元不為""
        request.getRequestDispatcher("/b")
        前台
            /代表的是伺服器的根目錄,注意:是伺服器的根目錄
            使用例子:
                html頁面,jsp頁面,重新導向
            "ip:port/"    http://localhost:8080/    webapps
        後台
            /代表的是項目的根目錄 注意:是項目的根目錄
            使用例子:
                request.getRequestDIspatcher("b")
                web.xml
                    <url-pattern>/a</url-pattern>
                    http://localhost:8080/helloWorld/a
            webapps/helloWorld ---hhtp://ip:port/helloWorld
        
     Servlet
       其路徑由web.xml中的<url-pattern>/basic</url-pattern>
        http://localhost:8888/jd1508/basic
        路徑並不是說他的類所在的目錄
     靜態資源
       其路徑由其所在的項目的實際路徑來決定,前提是沒有放在WEB-INF下
       webapps/jd1508/html/a.html
       http://localhost:8888/jd1508/html/a.html

     伺服器根目錄  webapps --  http://ip:port/
     項目的根目錄  webapps/jd1508  --  http://ip:port/jd1508
    
TOAHtmlServlet
    http://localhost:8888/jd1508/toAHtml
    --->  
    {  重新導向,day7/a.html  瀏覽器地址發生變化}
    http://localhost:8888/jd1508/day7/a.html
    a.html
      ---> TAServlet
      http://localhost:8888/jd1508/ta

TOAHtmlServlet
    http://localhost:8888/jd1508/toAHtml
    --->  
    {  內部跳轉,/day7/a.html  瀏覽器地址不發生變化}
    http://localhost:8888/jd1508/toAHtml
    a.html
      <a href="../a.html"></a>
      ---> TAServlet
      http://localhost:8888/jd1508/ta

web項目路徑問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.