创建个Servlet把下面代码贴进去就可以了
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
request.setCharacterEncoding("gb2312");
String filename=request.getParameter("name");
filename=new String(filename.getBytes("ISO-8859-1"));
response.setHeader("Content-disposition", "attachment;filename="+filename);
//此句是下载的关键
//下面的路径是我程序中默认的为E盘,实际应用中可以修改
BufferedInputStream bis=new BufferedInputStream(new FileInputStream("e:\\"+filename));
BufferedOutputStream bos=new BufferedOutputStream(response.getOutputStream());
byte[] b=new byte[2048];
int intread=0;
while((intread=bis.read(b, 0, b.length))!=-1)
{
bos.write(b, 0, intread);
}
bis.close();
bos.close();
}
[[it] 本帖最后由 marer 于 2008-2-16 13:40 编辑 [/it]]