//例如:项目名为test则返回/test
String webPath = request.getServletContext().getContextPath()
//获取webContent下路径
request.getSession().getServletContext().getRealPath(templatePath);
//获取src下文件
InputStream in = this.class.getClassLoader().getResourceAsStream("test.txt");
//获取src下文件路径
String filePath = this.class.getResource("/test.txt").getPath();
网友评论