【问题标题】:Display IOException into Primefaces Messages在 Primefaces 消息中显示 IOException
【发布时间】:2016-05-27 07:13:12
【问题描述】:

我正在尝试在 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。那么,还有其他方法可以做到这一点吗?

【问题讨论】:

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

标签: jsf jsf-2 primefaces


【解决方案1】:

试试这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-03
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多