web路徑格式總結(老杜)

2021-10-22 20:42:34 字數 1230 閱讀 2806

1、路徑的縮寫形式:(除了配置檔案中的,都需要加/專案名)

-"/專案名/資源路徑"

>

<

/a>

-"/專案名/資源路徑"

>

<

/form>

-重定向:response.

sendredirect

("專案名/資源路徑");

-**:request.

getrequestdispatcher

("/資源路徑).

forward

(request,response)

;-歡迎頁面(寫在web.xml中)

資源路徑<

/welcome-file>

<

/welcome-file-list>

-servlet路徑

islogin<

/servlet-name>

class

>orj.rzj.servlet.checkloginstatusservlet<

/servlet-

class

>

<

/servlet>

islogin<

/servlet-name>

/資源路徑<

/url-pattern>

//注意此處的資源路徑需要和action中的一樣

<

-cookie設定path

cookie.

setpath

("/專案名/資源路徑"

)//專案名可以由request.getcontentpath()+"/資源路徑"拿到

-servletcontext

getservletcontext()

;getrealpath

("/web-inf/classes/db.properties");

getrealpath

("/資源路徑");

2、url-pattern的編寫方式

2.1 url-pattern可以編寫多個

2.2 精確匹配

/hello<

/url-pattern>

/system/hello<

/url-pattern>

2.3 擴充套件匹配

/abc/*

2.4字尾匹配

*.do

2.5 全部匹配

/*`

web請求路徑獲取總結

1 返回工程名的相對路徑 testdemo request.getcontextpath request.getservletcontext getcontextpath 2 返回工程名的絕對路徑d workspace idea bootstrapdemo target bootstrapdemo ...

Web開發中的路徑問題總結

參考msdn 幾個符號的含義 代表 根目錄 images sampleimage.jpg 相當於 inetpub wwwroot image sampleimage.jpg 代表應用程式根目錄,運算子只能為伺服器控制項識別,並且位於伺服器 中.不能將 運算子用於客戶端元素.代表上一級目錄 bbs i...

web路徑問題

1.getrequesturi test testurl testurl.jsp 2.getcontextpath test 3.getservletpath testurl testurl.jsp 三 web.xml中的路徑 根路徑 locolhost 8080 專案名 servlet 對映 xx...