原始excel导出不起作用

原始excel导出不起作用

本文介绍了原始excel导出不起作用 - 不显示打开/保存对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将dtos的收藏导出为ex​​cel,并带有这样的原型(与正在工作的原始图形演示一样)。

I am trying to export collection of dtos to excel with primefaces like this (the same as primefaces showcase demo, which is working).

<p:commandButton value="Export">
    <p:dataExporter type="xls" target="results" fileName="game_statistics" />
</p:commandButton>

我用firebug观察并发出请求,响应看起来像文件内容,但没有文件保存/打开对话框弹出。
我正在使用mojarra 2.1.1和tomcat 6作为应用服务器。

I observed with firebug and it makes request, also the response looks like file content, but no file save/open dialog is popping.I am using mojarra 2.1.1 and tomcat 6 for app server.

推荐答案

< p:commandButton> 默认发送ajax请求。您不能用ajax下载文件。 Ajax由Javascript执行,但Javascript由于安全限制,无法强制另存为对话框,并传递ajax响应。

The <p:commandButton> sends by default an ajax request. You can't download files with ajax. Ajax is executed by Javascript, but Javascript has due to security restrictions no way to force a Save As dialogue and pass the ajax response to it.

您需要将 ajax =false添加到组件中:

You need to add ajax="false" to the component:

<p:commandButton value="Export" ajax="false">

或者只需使用常规的< h:commandButton>

<h:commandButton value="Export">

这篇关于原始excel导出不起作用 - 不显示打开/保存对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 13:40