怎样让上传附件在jsp页面上显示默认是下载

解决方案 »

  1.   

    我说了超链接不成,默认是在当前IE下打开,就是上传的附件,什么都有.txt,.doc等等
      

  2.   

    以前在ASP中有个“流下载”的东西,不知道在JSP中有没有,如果有的话就可以解决楼主的问题。
      

  3.   

    <input type="file" name="file" id="fileName"> 
    var path=document.getElementById("fileName").value;
    得到你附件里的文件的路径;
    然后再对这个文件进行下载的操作,就可以了啊。
      

  4.   

       1. <%@page language="java" contentType="application/x-msdownload" import="java.io.*,java.net.*" pageEncoding="gbk"%><%  
       2.       
       3.     response.reset();//可以加也可以不加  
       4.     response.setContentType("application/x-download");//设置为下载application/x-download  
       5.     // /../../退WEB-INF/classes两级到应用的根目录下去,注意Tomcat与WebLogic下面这一句得到的路径不同,WebLogic中路径最后没有/  
       6.     ServletContext context = session.getServletContext();  
       7.     String realContextPath = context.getRealPath("")+"\\plan\\计划数据模板.xls";   
       8.     String filenamedisplay = "计划数据模板.xls";  
       9.     filenamedisplay = URLEncoder.encode(filenamedisplay,"UTF-8");  
      10.     response.addHeader("Content-Disposition","attachment;filename=" + filenamedisplay);  
      11.       
      12.     OutputStream output = null;  
      13.     FileInputStream fis = null;  
      14.     try  
      15.     {  
      16.         output  = response.getOutputStream();  
      17. fis = new FileInputStream(realContextPath);  
      18.         byte[] b = new byte[1024];  
      19.         int i = 0;  
      20.   
      21.         while((i = fis.read(b)) > 0)  
      22.         {  
      23.             output.write(b, 0, i);  
      24.         }  
      25.         output.flush();  
      26.     }  
      27.     catch(Exception e)  
      28.     {  
      29.         System.out.println("Error!");  
      30.         e.printStackTrace();  
      31.     }  
      32.     finally  
      33.     {  
      34.         if(fis != null)  
      35.         {  
      36.             fis.close();  
      37.             fis = null;  
      38.         }  
      39.         if(output != null)  
      40.         {  
      41.             output.close();  
      42.             output = null;  
      43.         }  
      44.     }  
      45. %>  
      

  5.   

    response.setContentType("application/ms-download");  //指定为download 
    response.addHeader("Content-Disposition","attachment; filename=JLFZ_ERR.xls"); //设置文件头难道你要意思是这个?
      

  6.   

    runescape money
    runescape gold
    runescape power leveling
    cheap runescape power leveling
    rs powerleveling
    runescape accounts
    buy cheap runescape accounts
    cheapest runescape accounts
    rs accounts
    runescape gold farming
    runescape items
    runescape gold
    cheap runescape gold
    buy runescape gold
    runescape money
    cheap runescape money
    buy runescape money
    runescape accounts
    cheap runescape accounts
    buy runescape accounts
    runescape power leveling
    runescape powerleveling
    cheap runescape power leveling
    runescape gold farming
    runescape items
    runescape gold
    cheap runescape gold
    buy runescape gold
    runescape money
    cheap runescape money
    buy runescape money
    runescape accounts
    cheap runescape accounts
    buy runescape accounts
    runescape power leveling
    runescape powerleveling
    cheap runescape power leveling
    runescape gold farming
    runescape items
    runescape gold
    cheap runescape gold
    buy runescape gold
    runescape money
    cheap runescape money
    buy runescape money
    runescape accounts
    cheap runescape accounts
    buy runescape accounts
    runescape power leveling
    runescape powerleveling
    cheap runescape power leveling
    runescape gold farming
    runescape items
      

  7.   

    tomcat的话改mime码,把要下载的类型加进去