各种情况下获取web工程的路径

根据jsp, servlet, 普通类,可以把获得web工程的路径方法分为3种

1.jsp
<%=application.getRealPath("") %>
<%=request.getRealPath("") %>

2.servlet(当然包括了action等,只要能获得servlet)

  servletContext.getRealPath("");

3.普通类

  System.getProperty("user.dir")

原文地址:https://www.cnblogs.com/coffee/p/1630695.html