模拟资源管理器的小程序<%@ page import="java.io.*,java.util.*" contentType="text/html; charset=GBK"%><html><head>
<title>我的主页</title>
</head><body><%!
String root=null;
String current=null;
%><%
root="e:\\";
current=request.getParameter("current");
if(current == null){
current=root;
}
out.print("<a href=\"main.jsp?current="+root+"\">"+"返回到根"+root+"</a><br>");
if(!current.equals(root)){
String parent=new File(current).getParent();
out.print("<a href=\"main.jsp?current="+parent+"\">"+"返回到上一级"+"</a><br>");
}
out.print("当前路径:"+current+"<br><br><hr>");
File[] fl=new File(current).listFiles();
for(int i=0; i<fl.length; i++){
if(fl[i].isDirectory() && !fl[i].getName().equals("System Volume Information")){
String parent=fl[i].getParent();
out.print("<a href=\"main.jsp?current="+fl[i].getPath()+"\">"+fl[i].getName()+"</a><br>");
}else if(!fl[i].getName().equals("System Volume Information")){
out.print(fl[i].getName()+"<br>");
}
}
%>
</body></html>
一打开包含中文字符的子目录就出错,
帮忙看看如何解决,
谢谢!
<title>我的主页</title>
</head><body><%!
String root=null;
String current=null;
%><%
root="e:\\";
current=request.getParameter("current");
if(current == null){
current=root;
}
out.print("<a href=\"main.jsp?current="+root+"\">"+"返回到根"+root+"</a><br>");
if(!current.equals(root)){
String parent=new File(current).getParent();
out.print("<a href=\"main.jsp?current="+parent+"\">"+"返回到上一级"+"</a><br>");
}
out.print("当前路径:"+current+"<br><br><hr>");
File[] fl=new File(current).listFiles();
for(int i=0; i<fl.length; i++){
if(fl[i].isDirectory() && !fl[i].getName().equals("System Volume Information")){
String parent=fl[i].getParent();
out.print("<a href=\"main.jsp?current="+fl[i].getPath()+"\">"+fl[i].getName()+"</a><br>");
}else if(!fl[i].getName().equals("System Volume Information")){
out.print(fl[i].getName()+"<br>");
}
}
%>
</body></html>
一打开包含中文字符的子目录就出错,
帮忙看看如何解决,
谢谢!
解决方案 »
- s:iterator 遍历加超链接问题
- 关于js问题求助 刚接触 求助各位大侠 望多多指教啊!!
- 怎样用JSP写一个界面实现输入数据便能在同一界面显示查询到数据库表格的数据?
- 如何取到returnvalue的值
- 用户上传的头像怎么存到oracle中后sql中又怎么在用户登陆后显示在页面上啊
- netbeans 开发 struts,没有所见即所得功能。
- eclipse下运行servlet
- onclick调用多个函数
- 关于Servlet的问题!!!!!!
- Jquery弹出pup之类的操作
- jsp计算问题
- Spring依赖注入业务逻辑类,在JUnit测试可以获得,但在Action里却不能自动注入,求解!
<Connector connectionTimeout="20000" port="9090" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true" /><!--URLEncoding=""--> 表示用你页面的编码方式作为url编码方式,post和get都适合
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" crossContext="true" URIEncoding="UTF-8"/>
<Connector URIEncoding="GBK" port="8888"/>
就ok了
String curr=new String(current.getBytes("iso-8859-1"),"GBK");这是防止得到的current乱码的解决办法 试一下看可以不?