0514-86177077
9:00-17:00(工作日)
本文實例講述了jsp獲取url路徑的方法。分享給大家供大家參考,具體如下:
如果你請求的URL是 http://localhost:8080/demo/Index.jsp
request.getScheme() //輸出:http request.getServerName() //輸出: localhost request.getServerPort() //輸出: 8080 request.getContextPath() //輸出: /demo request.getRequestPath() //輸出: /Index.jsp request.gerRequestURI() //輸出: /demo/Index.jsp request.getRequestURL() //輸出: http://localhost:8080/demo/Index.jsp request.getRealPath("") //輸出:D:\apache-tomcat-6.0.10\webapps\demo
上面幾個我都驗證過了,除了request.getRequestPath() 無法使用外(估計這個函數(shù)已經(jīng)被廢棄掉了吧),其它的顯示都正確。
希望本文所述對大家JSP程序設計有所幫助。
標簽:烏蘭察布 山南 銅川 白銀 臨汾 自貢 吉林 開封
上一篇:JSP監(jiān)聽器用法分析
下一篇:jsp頁面常用的查詢及顯示方法分析
Copyright ? 1999-2012 誠信 合法 規(guī)范的巨人網(wǎng)絡通訊始建于2005年
蘇ICP備15040257號-8