2017-02-03 3 views
0

или, по крайней мере, я думаю, проблема в нем ...
В первой строке ниже журнал говорит, что поток не является нулевым.
во втором говорит, что в начале трассировки стека ошибок нет :struts.xml плохо выполнен?

01/02 07:30:07| INFO [http-apr-10080-exec-6] (BillAction.java:704) - completeExport() - [email protected] 
01/02 07:30:07| ERROR [http-apr-10080-exec-6] (CommonsLogger.java:34) - Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified f 
or this action. 
01/02 07:30:07| ERROR [http-apr-10080-exec-6] (CommonsLogger.java:38) - Exception occurred during processing request: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Chec 
k the <param name="inputName"> tag specified for this action. 
java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action. 
     at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:237) 
     at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) 
     at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367) 
     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:271) 
     at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256) 
     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) 
     at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) 
     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) 
     at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265) 
     at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 
     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) 
     at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138) 
etc... etc... 

Это код, который производит этот вид результата:

Struts.xml

<action name="exportExcelBill" 
    class="it.colmenjv.dlq.actions.BillAction" 
    method="exportBillToExcel"> 
    <interceptor-ref name="loginStack" /> 
    <result name="login">timeout.jsp</result> 
    <result name="success">jsp/common/intermeanExcel.jsp</result> 
</action> 
<action name="completeExport" 
    class="it.colmenjv.dlq.actions.BillAction" 
    method="completeExport"> 
    <interceptor-ref name="loginStack" /> 
    <result name="login">timeout.jsp</result> 
    <result name="success" type="stream"> 
     <param name="contentDisposition">attachment;filename="${reportFile}"</param> 
     <param name="contentType">application/vnd.ms-excel</param> 
     <param name="inputName">inputStream</param> 
     <param name="bufferSize">1024</param> 
    </result> 
</action> 

exportBillToExcel():

public String exportBillToExcel() { 
    XSSFWorkbook myWorkBook = new XSSFWorkbook(); 
    XSSFSheet mySheet = myWorkBook.createSheet(categ); 
    try { 

    ... etc. body of the method ... etc... 

    } 
    catch (Exception e) { 
     e.printStackTrace(); 
    } 
===> session.put("tmpstream", inputStream); 
    return SUCCESS; 
} 

intermeanExcel.jsp:

<head> 
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> 
    <script type="text/javascript" src="js/common/common.js"></script> 
</head> 

<body> 
    <%@ include file="./warningwait.jsp" %> 

    <script> 
     $(document).ready(function() { 
             closeBoxWait(previous_boxWait); 
             window.location = '<s:url namespace="/" action="completeExport"/>'; 
            }); 
    </script> 
</body> 

completeExport():

public String completeExport() { 
    inputStream = (InputStream)session.get("tmpstream"); 
    logger.info("completeExport() - inputStream="+inputStream); 
    return SUCCESS; 
} 

и, естественно, в классе присутствуют декларация InputStream и получить и установить методы.

где я ошибаюсь?

ответ

0

Вы можете показать свой метод getInputStream()? Возможно, есть какая-то ошибка. Вам не нужен метод setInputStream() для загрузки файла.

BTW: «парковка» входного потока в сеансе немного неудобна. Я не уверен, работает ли это. Я думаю, вам нужно создать inputStream в методе completeExport().

0

Пробуйте, определяющий тип результата в виде потока в struts.xml

<action name="exportExcelBill" 
    class="it.colmenjv.dlq.actions.BillAction" 
    method="exportBillToExcel"> 
    <interceptor-ref name="loginStack" /> 
    <result type = "stream"> 
     <param name="inputName">tmpstream</param> 
    </result> 
    <result name="login">timeout.jsp</result> 
    <result name="success">jsp/common/intermeanExcel.jsp</result> 
</action> 

Нет необходимости, чтобы поместить объект tmpstream в сессии в классе Java. Поскольку мы определили tmpstream в результате, он будет доступен в jsp для доступа.

Смежные вопросы