请教论坛前辈:
实现的是: 点击链接,下载以这个链接作为文件名的文件。
(使用jspSmartUpload作为上传下载组件)main.jsp中有链接代码如下:
<a href=”#” onClick=”downloadFile(this)”>测试下载.mpg </a>
function downloadFile(object) {
  var filePath = "/resource/ftp/" + eqidShow + "/" + bigCataShow + "/" + smallCataShow + "/" + object.innerHTML;
// eqidShow, bigCataShow, smallCataShow为目录名
// object.innerHTML 为待下载文件名
  window.location.href = "http://localhost:8080/DataInflux/datainflux/download.jsp?file=" + filePath;
}download.jsp代码如下:
<%@ page contentType="text/html" 
import="com.jspsmart.upload.*" %>
<%
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setContentDisposition(null);
String temp = request.getParameter("file");
String filePath = new String(temp.getBytes("ISO-8859-1"),"UTF-8");
System.out.println(filePath);
su.downloadFile(filePath);
%>控制台显示:
java.io.FileNotFoundException: \resource\ftp\20090101234912\音视�?地震灾害\测试下载.mpg (系统找不到指定的路径。)本应该打印:
\resource\ftp\20090101234912\音视频\地震灾害\测试下载.mpg就是这一个字的乱码问题导致找不到正确路径执行下载。请教前辈们:
我的这一句String filePath = new String(temp.getBytes("ISO-8859-1"),"UTF-8");写的是否有问题,尝试将utf-8改为别的支持中文的编码均不能实现。
望指教 ....