2016-06-19 103 views
1

在我的struts2應用程序中,我必須根據給定的值下載報告。在下載時,IE和Firefox會提示保存爲對話框。但谷歌瀏覽器會自動下載下載文件夾中的報告。 我在谷歌搜索得到的答案就像我需要添加octect-stream到contentType頭。我將它配置在我的struts xml中。仍然chrome不會提示保存爲對話。Save as Dialogue顯示在IE和Firefox中,但不顯示在Google Chrome中

下面是我的代碼

<action name="exportpsrdetails" class="com.action.Export_With_All"> 
<result name="success" type="stream"> 
<param name="contentType">application/vnd.ms-excel</param> 
<param name="contentType">octet-stream</param> 
<param name="contentDisposition">attachment;filename="ExportPsr.xls"</param> 
<param name="inputName">excelStream</param> </result> 
<result name="input">done.jsp</result> 
<result name="login" type="redirect">login.jsp</result> 
</action> 

PS:我不應該在Chrome中更改設置,以顯示另存爲對話框

+0

關於一般計算硬件和軟件的問題,除非堆棧溢出直接涉及主要用於編程的工具,否則不適用堆棧溢出。您可以在超級用戶上獲得幫助。 –

回答

0

我不得不面對這個和下面幫我。 Add:

<param name="Content-Disposition">attachment;filename="ExportPsr.xls"</param> 

你不需要刪除它!

<param name="contentDisposition">attachment;filename="ExportPsr.xls"</param> 
相關問題