我們?cè)谝粋€(gè)項(xiàng)目下面寫(xiě)的一個(gè)jsp頁(yè)面,怎么取得這個(gè)jsp頁(yè)面的當(dāng)前路徑呢?其實(shí)方法很簡(jiǎn)單
<%
String path = request.getContextPath()+request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/")+1);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
這樣basePath就是jsp頁(yè)面所在的路徑了。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。