得到web项目的根目录路径
System.getProperty("user.dir")//
String path = this.getServletContext().getRealPath("/WEB-INF/order_form.html");
得到类所在的路径
FormServlet.class.getClassLoader().getResourceAsStream("FileName");//可以直接读取文件
原文:https://www.cnblogs.com/jiangfeilong/p/10662447.html