如何下载 中文名称的文件

来源:百度知道 编辑:UC知道 时间:2024/06/25 05:37:23
比如:<a href="我.doc">aa</a>怎么样能成功啊。
算了,结了吧,没有我想要的。看看一楼挺辛苦,给你吧。

<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*"%>
<%!
public String toUtf8String(String s)
{
StringBuffer sb = new StringBuffer();
for (int i=0;i<s.length();i++) {
char c = s.charAt(i);
if (c >= 0 && c <= 255) {
sb.append(c);
} else {
byte[] b;
try {
b = Character.toString(c).getBytes("utf-8");
} catch (Exception ex) {
System.out.println(ex);
b = new byte[0];
}
for (int j = 0; j < b.length; j++) {
int k = b[j];
if (k < 0) k += 256;
sb.append("%" + Integer.toHexString(k).
toUpperCase());
}
}
}
return sb.toString();
}
%>
<%
String filename=new String(request.getParameter("filename").getBytes("ISO8859-1"),"GBK");
String dirName="D:/我.doc";
java.io.File ff=null;
String dd=dirName