获取项目根路径的四种方式
CreateTime--2018年3月2日11:39:52
Author:Marydon
<!-- 假设项目的请求根路径是"/demo" --> <!-- 方式一:EL表达式 --> ${pageContext.request.contextPath} <br>显示结果:"/demo"
应用:
<i:form id="AddForm" method="post" action="${pageContext.request.contextPath}/xnh/server/com/appro/CliAppro/getClicomdetailList.do" onSuccess="clicomDetail.onLoadData" onsubmit="javascript:return false"> </i:form>
<!-- 方式二:小脚本 --> <%=request.getContextPath() %> <br>显示结果:"/demo" <!-- 方式三:c标签 --> <c:url value="/index.jsp"></c:url> <br>显示结果:"/demo/index.jsp" <!-- 方式四:javascript --> <script type="text/javascript">var baseUrl = ‘<%=request.getContextPath()%>‘;</script> <br>显示结果:baseUrl ="/demo"
原文地址:https://www.cnblogs.com/Marydon20170307/p/8492405.html
时间: 2024-10-15 11:11:05