请教JSP下载问题
为了不让下载端知道真实的文件名,采用了下面这段程序,可是下载下来后的文件是空的(4个字节),请教为什么?
<%@page language= "java " import= "java.net.* " pageEncoding= "gb2312 "%>
<%
response.setContentType( "application/x-download ");//设置为下载application/x-download
String filenamedownload = "ns_modify.jsp ";//即将下载的文件的相对路径
String filenamedisplay = "abc123.jsp ";//下载文件时显示的文件保存名称
filenamedisplay = URLEncoder.encode(filenamedisplay, "UTF-8 ");
response.addHeader( "Content-Disposition ", "attachment;filename= " + filenamedisplay);
try
{
RequestDispatcher dispatcher = application.getRequestDispatcher(filenamedownload);
if(dispatcher != null)
{
dispatcher.forward(request,response);
}
response.flushBuffer();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
}
%>
------解决方案--------------------你的代码没有实现文件下载吧 ?好象只是文件名发给了客户端,下载用smartupload试试