如何解决下载文件后重新渲染组件
<h:commandLink id="number1" immediate="true" value="Downloadfile" action="#{businessBean.downloadFileAsZip}">
和downloadFileAsZip方法:
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext eContext = context.getExternalContext();
HttpServletResponse response = (HttpServletResponse) eContext.getResponse();
response.reset();
response.setContentType("application/zip");
response.setCharacterEncoding("UTF-8");
try (ServletoutputStream out = response.getoutputStream()) {
try (ZipOutputStream zOut = new ZipOutputStream(out,Charset.forName("cp866"))) {
byte[] data = ...some data....;
zOut.putNextEntry(new ZipEntry("some file"));
zOut.write(data);
zOut.closeEntry();
zOut.flush();
}
}
facesContext.responseComplete();
我猜不可能在同一响应中下载文件并重新呈现页面组件。有没有可能的解决方案,当点击按钮时,不仅下载文件,而且更新具有特定 id 的 jsf 组件?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。