在action或者Servlet中怎么得到项目的webRoot路径

在action或者Servlet中如何得到项目的webRoot路径String webRootPath request.getSession().getServletC

在action或者Servlet中如何得到项目的webRoot路径

String webRootPath = request.getSession().getServletContext().getRealPath("/"); //获得webRoot的路径

?