繁体   English   中英

如何在Websphere Portal上从Struts portlet显示Excel内容

[英]How to display Excel content from Struts portlet on Websphere Portal

这是代码,它不显示.csv文件:

public class ForwardAction extends MultiAction {
private static final String FILE_ERROR = "<h3><center>INVALID FILE</center></h3>";
    public ActionForward doVizualizare(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    StringBuffer sb = new StringBuffer();
    sb.append("Name,Email,Phone");
    sb.append(System.getProperty("line.separator"));
    sb.append("Naveen,naveen@ibm.com,111-111-111");

    OutputStream resOut = response.getOutputStream();
    try {
        response.setContentType("application/octet-stream"); 
        response.setHeader("Content-Disposition", "attachment; filename=\"a.csv\"");
        resOut.write(sb.toString().getBytes());
    } catch (Exception e) {
        resOut.write(FILE_ERROR.getBytes());
    }
    return null;
}
}

关闭并刷新输出流。

还检查是否调用了doVizualizare方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM