java 得到目录路径的方法

得到web项目的根目录路径

System.getProperty("user.dir")//
String path = this.getServletContext().getRealPath("/WEB-INF/order_form.html");

得到类所在的路径

FormServlet.class.getClassLoader().getResourceAsStream("FileName");//可以直接读取文件

猜你喜欢

转载自www.cnblogs.com/jiangfeilong/p/10662447.html
今日推荐