问题
Using struts-jquery
, I've created a page that allow an user to upload an excel file, and have the contents displayed without refreshing the page.
When I try to use execAndWait
interceptor to display a wait page as a remote page, I receive an exception telling me it can't find source of the file.
Can someone provide an answer?
Update I got null pointer exception for the uploaded file object
java.lang.NullPointerException at java.io.FileInputStream.(Unknown Source)
when I tried to pass a file object (from the jsp page) as an argument on the following line
Workbook.getWorkbook(file);
This is my action in the struts.xml
<action name="readExcel" class="th.co.gosoft.gosd.action.ImportDataAction" method="readExcel">
<interceptor-ref name="execAndWait">
<param name="delaySleepInterval">500</param>
</interceptor-ref>
<result name="wait">/jsp/goSD/wait.jsp</result>
<result name="success">/jsp/goSD/SearchTable/importPreview.jsp</result>
</action>
But when I remove the
interceptor-ref name="execAndWait"
Everything is fine.
回答1:
It is because you are using ONLY execAndWait
interceptor for your action. You need to define defaultStack
also.
<action name="readExcel" class="th.co.gosoft.gosd.action.ImportDataAction" method="readExcel">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="execAndWait">
<param name="delaySleepInterval">500</param>
</interceptor-ref>
<result name="wait">/jsp/goSD/wait.jsp</result>
<result name="success">/jsp/goSD/SearchTable/importPreview.jsp</result>
</action>
来源:https://stackoverflow.com/questions/14141329/cannot-find-file-source-when-processing-file-with-execandwait-interceptor-of-str