修改代码 显示结果
1.html
--------------------------------------------------------------
<Script language ="javascript">
function gotolist(){
var dir = document.getElementById("list").value;
window.location.href='list.jsp?dir='+dir;
}
</script>
<form name="myform" action="2.jsp" method ="post">
查看目录文件:<input type="text" name ="list">
<input type ="button" value="查看"onclick="gotolist()" > <br>
<input type ="submit" value="操作">
</form>
---------------------------------------------------------------------------
list.jsp 查看
------------------------------------------------------------------------------------
<%@page contentType ="text/html;charset=GBK"%>
<%@ page import="java.io.*" %>
<%
String dir ="";
if(dir == null){ dir ="c:/";}
File file = new File(dir);
if(file.exists()&&file.isDirectory()){
String f[] = file.list();
for(int i=0; i<f.length; i++){
out.print("<br>"+f[i]);
}
}
%>
-------------------------------------------------------------------------------------------
2.jsp 操作 (1.html还有其他输入框 没有写出 操作这个按钮针对那些没有写出的)
-------------------------------------------------------------------------------
...................................................