servlet的幾個函數

request.getContextPath     上下文,例如 /bignews1 (自帶 「 / 」)get

request.getScheme()    協議,例如HTTP域名

request.getServerName()  域名,例如localhostrequest

request.getServerPort()   端口,例如8080總結

 

總結:好比,String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() ,協議

結果就是http://localhost:8080/bignews1/ 端口

相關文章
相關標籤/搜索