JSP获取根目录

commom.jsp

<%@page import="java.io.*" %>
<%
String fileName = application.getRealPath(request.getRequestURI());
String rootPath = new File(new File(fileName).getParent()).getParent();
%>

原文地址:https://www.cnblogs.com/something/p/2880144.html