Fetch the repository succeeded.
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.io.*"%>
<%@ page import="java.net.URLEncoder"%>
<html>
<title></title>
<body>
<%
String name =request.getParameter("name");
String path = request.getContextPath("/");
if(name != null && !"".equals(name.trim())){
path = name;
}
int index = path.length();
File dir=new File(path);
File file[]=dir.listFiles();//用file对象的listFiles()方法返回指定目录下的文件
%>
<%
for(int i=0;i<file.length;i++)
{
if(file[i].isDirectory())
%>
<a href='index.jsp?name=<%=URLEncoder.encode(file[i].toString(), "utf-8")%>'>
<%
out.print("<br>"+file[i].toString().substring(index));
%>
</a>
<%
}
%>
</body>
</html>
Sign in for post a comment
Comment ( 0 )