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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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
Java xhtml不显示会话范围的值_Java_Jsf 2_Managed Bean - Fatal编程技术网

Java xhtml不显示会话范围的值

Java xhtml不显示会话范围的值,java,jsf-2,managed-bean,Java,Jsf 2,Managed Bean,我有一个会话范围的ManagedBean,它注入了另外两个会话范围的bean,它们都有适当的getter和setter 我的班级如下: @ManagedBean(name="oneClass") @SessionScoped public class OneClassController implements Serializable { @ManagedProperty(value="#{myOtherBean}") public AnotherClass another;

我有一个会话范围的ManagedBean,它注入了另外两个会话范围的bean,它们都有适当的getter和setter

我的班级如下:

@ManagedBean(name="oneClass")
@SessionScoped
public class OneClassController implements Serializable {

    @ManagedProperty(value="#{myOtherBean}")
    public AnotherClass another;

    @ManagedProperty(value="#{requestBean}")
    public RequestClass request;

    public String foo() {
        another = getAnotherService(request);
        return "page?faces-redirect=true";
    }

    //getters and setters for AnotherClass and RequestClass
}
现在,request类保存web服务请求的所有值。这些值在xhtml页面的表单中填写

当用户完成填写请求并通过按钮启动操作时,它进入
foo
方法。调试用正确的数据显示请求,当我调用它时,
另一个
被正确填充

现在,
page.xhtml
如下所示:

<h:outputText value="#{requestBean.agentId}" />
<h:outputText value="#{myOtherBean.name}" />
<h:outputText value="#{myOtherBean.lastname}" />
它们打印得很好

我在
web.xml
中设置了服务器的保存方法

顺便说一句,这不是我正在使用的真正的命名约定,但现在我在另一台没有任何IDE或JDK的计算机上,所以我正在尽我所能复制代码

如何在
页面中显示正确的值?

尝试使用

<h:outputText value="#{oneClass.another.name}" />
<h:outputText value="#{oneClass.another.lastname}" />

要查看sessionScope中的所有变量,您可以执行以下操作:

<h:outputText value="#{sessionScope}" /> 


这将确认“myOtherBean”是否在会话范围内。

感谢您的快速响应,我将在明天早上试用,看看会发生什么:)谢谢,它成功了。但为什么会这样?有没有一种方法可以让我直接使用另一个.name
?What's
other=getAnotherService(请求)@ManagedProperty
,代码>在那里做什么?
<h:outputText value="#{sessionScope}" />