将该内容放入一个空白的JSP文件中,保存为basepath.jsp,然后在需要引用的JSP文件中使用include标签引用。
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";request.setAttribute("basePath", basePath);%>
JSP——常用配置-获取项目跟路径
原文地址:http://www.cnblogs.com/weilu2/p/jsp_config_basepath.html