列出webroot下所有的jsp文件

  • Post author:
  • Post category:其他


private List<File> files = new ArrayList<File>();

	// private JspFileFilter jspFilter = new JspFileFilter();

	private List<File> listFiles(File dir) {
		if (dir.isFile() && dir.getName().indexOf(".jsp") != -1) {
			files.add(dir);
		} else {
			File[] subFiles = dir.listFiles();
			if (subFiles == null)
				return null;

			for (File ff : subFiles) {
				listFiles(ff);
			}
		}
		return files;
	}

结果如下:

CMSFile [name=index.jsp, path=C:\Users\Administrator\Desktop\p2p-cms-demo\service\src\main\


webapp\index.jsp


]

CMSFile [name=cms.jsp, path=C:\Users\Administrator\Desktop\p2p-cms-demo\service\src\main\


webapp\WEB-INF\jsp\cms.jsp


]

CMSFile [name=homePage.jsp, path=C:\Users\Administrator\Desktop\p2p-cms-demo\service\src\main\


webapp\WEB-INF\jsp\homePage.jsp


]



版权声明:本文为yx511500623原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。