日期:2014-05-18 浏览次数:20779 次
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.net.URL"%>
<%@page import="java.io.File"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URLDecoder"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%
File file=new File(application.getRealPath("/down"));
List<String> files=new ArrayList<String>();
for(String s:file.list()){
files.add(s);
}
pageContext.setAttribute("files",files);
%>
<p>文件列表</p>
<c:forEach var="filename" items="${files}">
<script>
var filename='${filename}';
var str="<a href='<%=application.getContextPath()%>/down/"+filename+"'>"+filename+"</a>";
document.write(str);
</script>
</c:forEach>
</body>
</html>