ServletContext context = getServletContext();
String rootPath = context.getRealPath("/");
log.info("root path[" + rootPath + "]");
//如果最后一位没有分隔符,则加上
if (File.separatorChar != rootPath.charAt(rootPath.length() - 1))
{
rootPath = rootPath + File.separatorChar;
}
log.info("root path[" + rootPath + "]");
String config = getInitParameter("config");
File rootDir = new File(rootPath + "WEB-INF" + File.separatorChar);
File[] childFile = FileUtils.getFiles(rootDir, config);
获取工程路径(兼容windows和linux)
最新推荐文章于 2021-02-12 10:08:35 发布