开发者

Excel Template in JBoss Static Folder

I recently migrated from Tomcat to JBoss and during the migration we moved the static content into a static folder. One item we moved was an excel template used for reports. If I keep the excel file in the same folder as the .java file and just have the file name rather than path it works, but when I try to reference the excel file in the "static" folder it never loads. Any suggestions? Thanks!

public ActionForward ADReports(ActionMapping mapping, ActionForm form,
        HttpServletRequest req, HttpServletResponse response) throws Exception {
    String sbcuid = (String) req.getSession().getAttribute("id");       adRowCount=1;
    String excelName = "Report";
    OutputStream out = null;

    try
    {
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment; filename="+excelName+".xls");
        Workbook template = Workbook.getWorkbook(this.getClass().getResourceAsStream("/static/RRTemplate.xls"));
        WritableWorkbook workbook = Workbook.createWorkbook(response.getOutputStream(), template);
        WritableSheet 开发者_JAVA技巧worksheet = workbook.getSheet(0);


getResourceAsStream() searches the classpath looking for the resource, I guess your new static folder isn't on your classpath. Not sure what arguments Workbook.getWorkbook() takes, but you may have to consider using a FileInputStream or similar in place of your current construct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜