使用 JSF 进行页面导航
也许这是一个简单的问题,但我不知道它的答案。
我有一个项目,myProject。在 webContent 中,我有文件 home.xhtml、leave.html,还有另外 2 个文件夹:cats 和 dogs。在 cats 目录中,我有一个页面 cat.xhtml,在目录 dogs 中,我有一个页面 dogs.xhtml。
我想从每个页面(主页,猫,狗)转到页面leave.html 在每个文件中都有一个 commandLink
<h:form>
<h:outputLink value="leave.html" action="#{myBean.leave}">
<f:verbatim>Leave</f:verbatim>
</h:outputLink>
</h:form>
myBean
方法 leave
返回一个字符串“leave”
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>leave</from-outcome>
<to-view-id>/leave.html</to-view-id>
</navigation-case>
</navigation-rule>
但这不起作用。 我还尝试使用
或者添加一个新文件夹leave并将leave.html页面放入其中。 我使用
或
但都有相同的结果 HTTP Status 404 /myProject/cats/leave.htlm 类型 状态报告
消息/myProject/cats/leave.htlm
描述请求的资源(/myProject/cats/leave.htlm)是 不可用。
Probably this is a simple question, but i don't know its answer.
I have a project, myProject. In webContent I have the files home.xhtml, leave.html and I have 2 other folders: cats and dogs. In the cats directoy I have a page cat.xhtml, and in the directory dogs I have a page dogs.xhtml.
I want to go from each page (home,cats, dogs) to page leave.html
In each file there is a commandLink
<h:form>
<h:outputLink value="leave.html" action="#{myBean.leave}">
<f:verbatim>Leave</f:verbatim>
</h:outputLink>
</h:form>
myBean
in method leave
returns a string "leave"
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>leave</from-outcome>
<to-view-id>/leave.html</to-view-id>
</navigation-case>
</navigation-rule>
But this doesn't work.
I also tried using <to-view-id>../leave.html</to-view-id>
or add a new folder leave and put in there the leave.html page.
I used <to-view-id>/leave/leave.html</to-view-id>
or<to-view-id>/../leave.html</to-view-id>
but all have the same result HTTP Status 404 /myProject/cats/leave.htlm
type Status report
message /myProject/cats/leave.htlm
description The requested resource ( /myProject/cats/leave.htlm) is
not available.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的导航无法正常工作,因为页面始终会转到“leave.html”。 h:outpuLink 使用 value 属性进行导航。
我建议您使用 h:commandLink 并使用 value 属性来显示链接(Leave),使用 action 属性来显示来自结果字符串。
Your navigation is not working because page is always going to "leave.html". h:outpuLink uses value property for navigation.
I suggest you use h:commandLink and use value property for display link (Leave) and action property for from-outcome string.