JSP页面中“ path ”和 “ basepath ”

自动创建高级JSP页面头部,以下代码:

 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

---------------------

http://localhost:8888/Hotel/pages/query.jsp

---------------------

request.getContextPath() 获得:Hotel

request.getScheme()  获得:http

request.getServerName()  获得:localhost

request.getServerPort() 获得:8088

path 获得:Hotel

basePath 获得:http://localhost:8888/YJAccountQuery/

 

则:若在此页面链接访问pages文件夹下updatePW.jsp,<a href="/pages/updatePW.jsp">CHANGE</a>

你可能感兴趣的:(jsp,String,Path)