jsp怎么获取项目的路径

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


path就是项目名字的前边有 "/" ,例如你的项目名字叫做 Apple ,那么 path = /Apple。

basePath就是项目的完整路径,bathPath = http://localhost:8080/Apple

你可能感兴趣的:(jsp)