4

当 h:commandlink 与 target="_blank" 一起使用时,我的 h:commandLink 正在同一页面/窗口上打开/预览 pdf 文档。我希望它在浏览器的新标签页中打开

错误可能在哪里?

Preview.xhtml 代码:

<h:commandLink  id="DocUpoadPreview" action="#{documentController.previewUploadedFile}" value="Preview" target="_blank" >

             </h:commandLink>

在 previewuploadedFile() 动作加密/解密和其他一些带有 pdf 的过程是必需的,这就是为什么需要使用,这就是为什么不在这里使用 h:outputlink。在操作过程之后,我想重定向到另一个页面(previewUploadedDoc.xhtml),该页面使用 primefaces p:media 标签来预览文档。

public String previewUploadedFile() throws Exception {


  //decryption process and adding water mark here//
FacesContext.getCurrentInstance().getExternalContext()
        .redirect("previewUploadedDoc.xhtml");}
4

2 回答 2

3

Try it:

<h:commandLink  id="DocUpoadPreview" action="#{documentController.previewUploadedFile}" value="Preview" target="_new" />
于 2014-06-04T21:13:28.817 回答
-1

target="_new" 不是目标的有效值。它将 _new 定义为新页面的名称。

这是有效值: https ://www.w3schools.com/tags/att_a_target.asp

于 2019-02-26T12:12:50.677 回答