1

我在 JSF 2.3 和 CDI 应用程序中发现 bean 有问题。我正在使用 Glassfish 5.0、Java 8 (1.8.0_151)。我的文件:

面孔-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
              version="2.3">


</faces-config>

LocaleBean:

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
public class LocaleBean implements Serializable {

}

向此 bean 提交表单后 Glassfish 日志中的消息:

javax.el.PropertyNotFoundException: /home.xhtml @15,81 value="#{localeBean.language}": 目标不可达,标识符'localeBean'解析为空

只有当我使用下面列出的导入而不是 javax.enterprise.context 包中的 @Named 和 @SessionScoped 时,表单提交才有效。

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

但是两者在 JSF 2.3 中都被弃用了。

有什么想法吗?谢谢!

4

1 回答 1

0

我在 GitHub 上的这个主题中找到了解决方案及其描述:

https://github.com/javaserverfaces/mojarra/issues/4264

于 2017-11-05T13:02:37.183 回答