JSP取得绝对路径

代码” ${pageContext.request.contextPath}”的作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的。

<!--使用绝对路径的方式引入CSS文件-->
<link rel="stylesheet" href="${pageContext.request.contextPath}/themes/default/css/ueditor.css" type="text/css"/>
<!--使用绝对路径的方式引入JavaScript脚本-->
<script type="text/javascript" src="${pageContext.request.contextPath}/ueditor1_3_6-gbk-jsp/ueditor.config.js"></script>

使用<%=request.getContextPath()%>和使用${pageContext.request.contextPath}达到同样的效果

<script type="text/javascript" src="<%=request.getContextPath()%>/ueditor1_3_6-gbk-jsp/ueditor.all.js"></script>
原文地址:https://www.cnblogs.com/XJJD/p/7643221.html