想不想在写项目时有个页面可以访问你WebRoot下的所有文件,便于你知道你的文件分布结构

遍历你项目下的文件和文件夹结构,并可以依次展开,便于开发时快速定位


<%-- 
    把这个页面放到你的项目的WebRoot任意目录下,访问该页面你可以看到你项目的WebRoot下的整个文件目录结构,不可以快速访问它们
    
    @version $Date: 2012-10-19 20:49:39
    
    @author WangJun
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title><%=path.substring(1, 6)%>页面导航</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
	margin: 0 auto;
	padding: 0;
	width: 980px;
}

#header {
	width: 980px;
	height: 45px;
	margin-bottom: 5px;
}

#title {
	margin: 5px auto;
	font-size: 5ex;
	font-weight: normal;
	float: left;
}
#content {
	padding: 25px 55px;
	border: thin inset;
	text-decoration: none;
}

ol {
	line-height: 3.6ex;
}

#url,#directory {
	width: 435px;
	display: table-cell;
}

#url li,#directory li {
	display: list-item;
}

#foot {
	color: green;
	text-align: right;
}
</style>
</head>

<body>


	<div id="header">
		<span id="title">PKSoft Study</span>
	</div>
	<hr>

	<div id="content">
		<h3>页面导航</h3>
		<hr>

		<%
			String dir = request.getParameter("dir");
			if (dir == null)
				dir = "/";
			else
				dir = "/" + dir;
			Set<String> urls = (HashSet<String>) this.getServletContext()
					.getResourcePaths(dir);
			String webRootUrl = "";
			String webRootDirectory = "";
			for (String url : urls) {
				if (url.indexOf(".") >= 0 || url.indexOf(".") >= 0)
					webRootUrl += "<li><a href='" + url.substring(1) + "'>"
							+ url.substring(1) + "</a></li>";
				else
					webRootDirectory += "<li><a href='index.jsp?dir="
							+ url.substring(1) + "'>" + url.substring(1)
							+ "</a></li>";
			}
			out.print("<div id=\"url\"> <h5>文件</h5><ol>" + webRootUrl
					+ " </ol></div>");
			out.print("<div id=\"directory\"><h5>文件夹</h5><ol>"
					+ webRootDirectory + "</ol></div>");
			out.flush();
		%>

		<br> <br> <br>
	</div>
	<div id="foot">copyright WangJun</div>

</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值