jsp中路徑的問題。。。

2022-03-17 20:50:54 字數 1333 閱讀 5535

剛剛學jsp的時候都是從看別人的**,模仿著做,但是這樣也有看不懂的地方,這個相對路徑和絕對路徑就讓我糾結了好久。。所以我自己弄了乙個demo實驗了一下,試驗出結果了,但是不明白原理,糾結了一天,終於問別人知道了,最關鍵的是我自己看到「位址列」才理解啊。。。所有不能離了題。先附上demo的**:

web.xml中德配置this is the description of my j2ee component

this is the display name of my j2ee component     tiaozhuanservlet     org.gsh.wh.servlet.tiaozhuanservlet  

而如果你的配置如下: this is the description of my j2ee component

this is the display name of my j2ee component     tiaozhuanservlet     org.gsh.wh.servlet.tiaozhuanservlet  

則相對路徑是:http://localhost/test2下面照「show.jsp」,而不加的話:依然跳轉http://localhost/test2/tiaozhuanservlet 往"show.jsp"跳轉,結果為:http://localhost/test2/show.jsp,所以加和不加一樣

demo的

jsp中路徑問題

超連結 的引用路徑,若是引用自己專案的資源,則引用路徑則是從當前路徑開始去找,若是請求頁面資源就不必說了,並且介面的對映路徑也是如此,將會從當前目錄去尋找藉口路徑。例如當前路徑 http localhost 8888 l learn login.jsp web.xml learn loginserv...

jsp中路徑的問題

工作快一年了,直到今天才理解下面 的含義。string path request.getcontextpath string basepath request.getscheme request.getservername request.getserverport path 很簡單上面的 定義了乙...

關於jsp中路徑的問題

討論這個問題,先建立3個.jsp檔案,檔案位置如圖 為了對比,首先使用myeclipse建立.jsp檔案時把下面這幾句話刪掉。string path request.getcontextpath string basepath request.getscheme request.getservern...