在 Myfaces 中找不到 getFlash() 方法

发布于 2024-12-03 15:00:55 字数 390 浏览 6 评论 0原文

FacesContext.getCurrentInstance().getExternalContext().getFlash()

我尝试使用上面的代码,似乎 Myfaces 的 JSF2 实现中不存在 getFlash() 。我怎样才能访问它。

上面的行给了我这个错误

The method getFlash() is undefined for the type Object

这是我的导入没有问题

import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
FacesContext.getCurrentInstance().getExternalContext().getFlash()

I am trying to use above code seems like getFlash() does not exist in JSF2 implementation of Myfaces. How how can I access it.

Above line gives me this error

The method getFlash() is undefined for the type Object

Here are my imports no issues with them

import javax.faces.context.FacesContext;
import javax.faces.context.Flash;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三月梨花 2024-12-10 15:00:55

此编译错误表明您实际上正在针对 JSF 1.2 而不是 JSF 2.0 构建项目。

不过,Java EE 5 环境支持 JSF 2.0。仔细检查您是否有正确的 JSF 2.0 JAR 文件。如果需要,提取 API 和 impl JAR 文件并读取 /META-INF/MANIFEST.MF 文件。仔细检查您的faces-config.xml 文件是否声明符合 JSF 2.0。仔细检查您的 IDE 项目是否配置了 JSF 2.0 方面,并且在构建路径中使用 JSF 2.0 库。仔细检查您的目标容器是否未附带内置 JSF 1.2 库,或者至少已将其关闭。

This compilation error suggests that you're actually building your project against JSF 1.2 instead of JSF 2.0. The tag on your question only confirms this more as this is usually tied to JSF 1.2.

JSF 2.0 is however supported on a Java EE 5 environment. Doublecheck if you have the proper JSF 2.0 JAR files. Extract if necessary the API and impl JAR files and read the /META-INF/MANIFEST.MF file. Doublecheck if your faces-config.xml file is declared conform JSF 2.0. Doublecheck if your IDE's project is configured with a JSF 2.0 facet and is using the JSF 2.0 libs in build path. Doublecheck if your target container doesn't ship with builtin JSF 1.2 libraries or that this is at least turned off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文