Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.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 JSF导航规则在菜单上不起作用_Java_Jsf - Fatal编程技术网

Java JSF导航规则在菜单上不起作用

Java JSF导航规则在菜单上不起作用,java,jsf,Java,Jsf,menu.xhtml上的我的commandlink不起作用。我在WebContent下的template文件夹中有menu.xhtml,在WebContent下的pages文件夹中也有list.xhtml。当我单击menu.xhtml中的链接时,它没有进入list.xhtml页面,但它确实到达了被调用的方法 menu.xhtml <h:commandLink action="#{UserManagerBean.goListPage}">

menu.xhtml上的我的commandlink不起作用。我在WebContent下的template文件夹中有menu.xhtml,在WebContent下的pages文件夹中也有list.xhtml。当我单击menu.xhtml中的链接时,它没有进入list.xhtml页面,但它确实到达了被调用的方法

menu.xhtml

<h:commandLink action="#{UserManagerBean.goListPage}">
                         <h:outputText value="List"/>     
                     </h:commandLink>

faces-config.xml

<navigation-rule>
        <display-name>template/menu.xhtml</display-name>
        <from-view-id>/template/menu.xhtml</from-view-id>
        <navigation-case>
            <from-action>#{UserManagerBean.goListPage}</from-action>
            <from-outcome>success</from-outcome>
            <to-view-id>/pages/list.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>

template/menu.xhtml
/template/menu.xhtml
#{UserManagerBean.goListPage}
成功
/pages/list.xhtml

请帮帮我,谢谢。

这似乎是我的问题

 <from-view-id>/template/menu.xhtml</from-view-id>  
/template/menu.xhtml
我想你是把这个菜单作为模板的一部分包含在某个页面中

试着改变一下

 <from-view-id>/pages/*</from-view-id> 
/pages/*

但是在这里,您必须确保您的
{UserManagerBean.goListPage}
没有被
/pages/
中的任何其他页面调用或相应地处理。

菜单中发布您的代码。xhtml
-来自
faces config.xml
的链接和导航规则是否确定您的方法返回
成功
?是,我确信它返回成功你能发布goListPage方法代码吗?@aFish check update
/pages/*
在我更改为/pages/*后它会工作的。我可以知道为什么吗?我的模板位于模板文件夹中,应该是/template/*但为什么是/pages/*?非常感谢,这是因为您的菜单在实际页面中使用,而不是单独使用,并且您的实际页面位于
/pages/
继续,将其标记为答案