获取根目录

    xiaoxiao2026-03-18  11

    JSP中: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="ctx" value="${pageContext.request.contextPath}"/> js中 : function getRootPath(){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); return postPath; } java中: System.getProperty("web.root")

    在web.xml中配置 <context-param> <span style="white-space:pre"> </span><param-name>webAppRootKey</param-name> <param-value>web.root</param-value> </context-param><pre name="code" class="html"><listener> <listener-class>org.springframework.web.util.WebAppRootListener</listener-class> </listener>
    转载请注明原文地址: https://ju.6miu.com/read-1308076.html
    最新回复(0)