我有一个.xhtml页面:
<f:event type="preRenderView" listener="#{suspendBean.getSuspendBeanHandler()}" />
和方法getSuspendBeanHandler();
ByteArrayOutputStream baosPDF=new ByteArrayOutputStream();
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
ec.responseReset();
ec.setResponseContentType("application/pdf");
ec.setResponseContentLength(baosPDF.size());
ec.setResponseHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
OutputStream output = ec.getResponseOutputStream();
.....
baosPDF.writeTo(output);
fc.responseComplete();
我想在新的Windows浏览器中显示PDF,很可能是一个新的弹出窗口。