<legend id='uJsek'><style id='uJsek'><dir id='uJsek'><q id='uJsek'></q></dir></style></legend>

        <bdo id='uJsek'></bdo><ul id='uJsek'></ul>
    1. <tfoot id='uJsek'></tfoot>

        <small id='uJsek'></small><noframes id='uJsek'>

        <i id='uJsek'><tr id='uJsek'><dt id='uJsek'><q id='uJsek'><span id='uJsek'><b id='uJsek'><form id='uJsek'><ins id='uJsek'></ins><ul id='uJsek'></ul><sub id='uJsek'></sub></form><legend id='uJsek'></legend><bdo id='uJsek'><pre id='uJsek'><center id='uJsek'></center></pre></bdo></b><th id='uJsek'></th></span></q></dt></tr></i><div id='uJsek'><tfoot id='uJsek'></tfoot><dl id='uJsek'><fieldset id='uJsek'></fieldset></dl></div>
      1. java.lang.IllegalStateException: getOutputStream() 已经为此响应调用

        时间:2023-09-25
        <legend id='uwlGf'><style id='uwlGf'><dir id='uwlGf'><q id='uwlGf'></q></dir></style></legend>
        <i id='uwlGf'><tr id='uwlGf'><dt id='uwlGf'><q id='uwlGf'><span id='uwlGf'><b id='uwlGf'><form id='uwlGf'><ins id='uwlGf'></ins><ul id='uwlGf'></ul><sub id='uwlGf'></sub></form><legend id='uwlGf'></legend><bdo id='uwlGf'><pre id='uwlGf'><center id='uwlGf'></center></pre></bdo></b><th id='uwlGf'></th></span></q></dt></tr></i><div id='uwlGf'><tfoot id='uwlGf'></tfoot><dl id='uwlGf'><fieldset id='uwlGf'></fieldset></dl></div>

            <tbody id='uwlGf'></tbody>
            <tfoot id='uwlGf'></tfoot>

              • <bdo id='uwlGf'></bdo><ul id='uwlGf'></ul>

              • <small id='uwlGf'></small><noframes id='uwlGf'>

                • 本文介绍了java.lang.IllegalStateException: getOutputStream() 已经为此响应调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我得到以下异常的代码

                  Here is my code for which I am getting the following exception

                  HTTP Status 500 - Unable to show problem report: java.lang.IllegalStateException: getOutputStream() has already been called for this response
                  

                  代码:

                  WorkbookSettings wbSettings = new WorkbookSettings();    
                  OutputStream outStream = null;
                              
                  try
                  {               
                    wbSettings.setLocale(new Locale("en", "EN"));             
                    response.setContentType("application/vnd.ms-excel");                  
                    outStream= response.getOutputStream();                
                    response.setHeader("Content-Disposition", "attachment; filename=/timesheet.xls");             
                    WritableWorkbook workbook = Workbook.createWorkbook(outStream, wbSettings);              
                    workbook.createSheet("Report", 0);               
                    WritableSheet excelSheet = workbook.getSheet(0);              
                    service.createLabel(excelSheet);              
                    service.createContent(excelSheet);                    
                    workbook.write();             
                    workbook.close();             
                    outStream.flush();               
                    outStream.close();                
                  }               
                  catch(Exception e)
                  {
                  }           
                  finally
                  {               
                    //outStream.close();      
                  }   
                  return "generateReport";
                  

                  我的 Struts.xml 看起来像这样:

                  My Struts.xml looks like this:

                  <result type="stream" name="generateReport">                   
                   <param name="contentType">"application/vnd.ms-excel"</param>                  
                   <param name="inputName">excelstream</param>                  
                   <param name="contentDisposition">contentDisposition</param>                   
                   <param name="bufferSize">1024</param>              
                  </result>
                  

                  在 JSP 中,我只是给出了一个按钮,它提供了 open, save 对话框.单击该按钮后,我得到了异常.

                  In JSP, I am just giving a button which gives me open, save dialog box. After clicking that button I am getting the exception.

                  如何避免这种情况?

                  推荐答案

                  删除关闭 %> 和打开 <% 之间的所有空格和换行符和在顶部使用 <%@page trimDirectiveWhitespaces="true" %> 可以解决这个问题.

                  Remove all space and linebreaks between closing %> and opening <% and use <%@page trimDirectiveWhitespaces="true" %> at top can solve this issue.

                  这篇关于java.lang.IllegalStateException: getOutputStream() 已经为此响应调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Struts 2 中 Json 插件的问题 下一篇:如何在struts2中仅获取特定字段作为响应

                  相关文章

                  <small id='PIgbK'></small><noframes id='PIgbK'>

                  <legend id='PIgbK'><style id='PIgbK'><dir id='PIgbK'><q id='PIgbK'></q></dir></style></legend>

                    <tfoot id='PIgbK'></tfoot>
                  1. <i id='PIgbK'><tr id='PIgbK'><dt id='PIgbK'><q id='PIgbK'><span id='PIgbK'><b id='PIgbK'><form id='PIgbK'><ins id='PIgbK'></ins><ul id='PIgbK'></ul><sub id='PIgbK'></sub></form><legend id='PIgbK'></legend><bdo id='PIgbK'><pre id='PIgbK'><center id='PIgbK'></center></pre></bdo></b><th id='PIgbK'></th></span></q></dt></tr></i><div id='PIgbK'><tfoot id='PIgbK'></tfoot><dl id='PIgbK'><fieldset id='PIgbK'></fieldset></dl></div>

                      • <bdo id='PIgbK'></bdo><ul id='PIgbK'></ul>