Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 在Primefaces消息中显示IOException_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf 在Primefaces消息中显示IOException

Jsf 在Primefaces消息中显示IOException,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我试图在Primefaces消息中显示IOException,但文本格式不正确 在我的代码中,我捕获了异常: } catch (Exception ex) { System.out.println(ex); msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null,ex.toString()); facesGetCurrentInstance(msg); } 然后添加消息: public void f

我试图在Primefaces消息中显示IOException,但文本格式不正确

在我的代码中,我捕获了异常:

} catch (Exception ex) {
      System.out.println(ex);
      msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null,ex.toString());
      facesGetCurrentInstance(msg);
}
然后添加消息:

public void facesGetCurrentInstance(FacesMessage msg) {
    FacesContext.getCurrentInstance().addMessage(null, msg);
 }
在XHTML中,我使用咆哮来显示消息

<p:growl id="messages" showDetail="true" sticky="true" autoUpdate="true"   />

到目前为止,一切正常,但我对信息的显示方式有疑问。我假设这是因为我正在使用.toString。那么,还有别的办法吗

试试这个:

FacesContext.getCurrentInstance().addMessage(FacesMessage.SEVERITY_ERROR,exception.getMessage());

您是否尝试显示其他没有空格的长字符串