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

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

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

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

  servletContext.getRealPath("");

3.普通类

  System.getProperty("user.dir")

posted @ 2009-12-23 15:52  咖啡不苦  阅读(306)  评论(0编辑  收藏  举报