当前页面: 开发资料首页 → JSP 专题 → 请教一个jsp绝对路径和相对路径的问题
摘要: 请教一个jsp绝对路径和相对路径的问题
<%@ page import="java.io.*"%> there are list all the file of .jsp in the document please input jsp file name,in order to load this file:
<%! class FileJSP implements FilenameFilter
{
String str=null;
FileJSP(String s)
{
str="."+s;
}
public boolean accept(File dir,String name)
{
return name.endsWith(str);
}
}
%>
<body bgcolor=cyan>
<%File dir=new File("c:/test");
FileJSP file_jsp=new FileJSP("jsp");
String file_name[]=dir.list(file_jsp);
for(int i=0;i
out.print("
"+file_name[i]);
}
%>
<form action="loadfile.jsp" method=post name=form>
<input type="text" name="ok">
<input type="submit" value="send" name=submit>
</form>
<%--here: --%> <%String fileName="";
fileName=fileName+request.getParameter("ok");
%>
Excuete :<%=fileName%>
the result is:
//加载指定了绝对路径的目录的文件为什么不可以?
//比如:here处改为:
//<%String fileName="c:/jsp/",输入文件名点击加载,根本就没有
//加载指定文件,请高手指教!!!
</body>