zoukankan      html  css  js  c++  java
  • struts2 上传与下载

    1.Struts.xml

    <action name="addfileAction" class="Action.addfileAction">
    <interceptor-ref name="fileUpload">
    <param name="maixmumSize">1024000000</param>
    </interceptor-ref>
    <interceptor-ref name="defaultStack" />
    <param name="savePath">/save</param>
    <result name="success">${path}/success.jsp</result>
    <result name="input">/file/Fileup.jsp </result>
    </action>

    <action name="FlieDownAction" class="Action.FlieDownAction">
    <result name="success" type="stream">
    <param name="contentType">
    application/octet-stream;charset=Iso8859-1
    </param>
    <param name="contentDisposition">、
    attachment;filename="${downloadFileName}"
    </param>
    </result>
    </action>

    2.Action

    public InputStream getInputStream() throws MalformedURLException{
    String path="/save/"+filename;
    return ServletActionContext.getServletContext().getResourceAsStream(path);
    }

    public String getDownloadFileName(){

    String downloadFileName= new String(getFilename().getBytes("gbk"), "iso-8859-1");

    return downloadFileName;

    }

  • 相关阅读:
    fixed解决方案
    阿里巴巴全部行业分类
    下边的flash挡住了上面的元素
    Response.Status
    分割DataTable
    window.print() 指定打印的区域
    oracle .1
    最新:电视台mms地址在线观看
    Access 时间比较错误
    Entity Framework linq
  • 原文地址:https://www.cnblogs.com/guoke-jsp/p/4344479.html
Copyright © 2011-2022 走看看