JSP——常用配置-获取项目跟路径

将该内容放入一个空白的JSP文件中,保存为basepath.jsp,然后在需要引用的JSP文件中使用include标签引用。

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

 

posted @ 2017-11-14 10:57  大肥肥就是我  阅读(288)  评论(0编辑  收藏  举报