CommandButton不会从操作中返回附件(txt文件)。我没有错误。只是什么都没发生。
Java代码:
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
response.setContentType("application/txt");
response.setHeader("Content-Disposition","attachment;filename=file.txt");
IOUtils.copy(new StringReader("TEST"), response.getOutputStream());
facesContext.responseComplete();
facesContext.renderResponse();iceFaces - jspx
<ice:commandButton
id="downloadBtn"
action="#{contentsBean.downloadAsZip}"
value="txt" partialSubmit="true" immediate = "true" >
</ice:commandButton>我尝试使用commandButton,因为我不能使用ice:outputResource。
发布于 2016-08-25 16:52:55
您可以在网站上使用ice:outputResource作为不可见按钮。当用户单击commandButton时,您可以在ice上导出类似于"onClick“的内容:使用javaScript的outputResource。
https://stackoverflow.com/questions/34741573
复制相似问题