我有自己的 ExceptionHandlerWrapper 来管理 ViewExpiredException 和其他错误。
这个想法是捕获错误,添加一些错误消息并重定向(使用重定向,而不是导航)到索引页面,其中将显示错误消息。
fc.getExternalContext().getFlash().setKeepMessages(true);
Messages.addFlashError(null, "my message");
Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
flash.put("foo", "hello");
fc.getExternalContext().redirect("index.xhtml");
但是,不存储闪存消息(但 foo 存在于闪存范围内)。
这在 mojarra 中工作,但我转移到 myfaces 2.2.4 并且它停止工作。任何想法?(也使用omnifaces 1.8.1)谢谢。