jsp 路径问题

EL表达式:${pageContext.request.contextPath}或者直接传统的jsp:<%=request.getContextPath()%> 获取的结果都是项目名

想要获取项目的绝对路径和端口号:

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

  

原文地址:https://www.cnblogs.com/LinsenLi/p/9885931.html