//1
String path = ContextLoader.getCurrentWebApplicationContext().getServletContext().getRealPath("/");
//2
public void contextInitialized(ServletContextEvent sce) {
String path = sce.getServletContext().getRealPath("/");
}
//3 在Web项目中获取classes的路径
this.getClass().getResource("/").getPath()