无法使用 from-view-id '/pages/index.xhtml' 找到匹配的导航案例 [英] Unable to find matching navigation case with from-view-id '/pages/index.xhtml'

查看:16
本文介绍了无法使用 from-view-id '/pages/index.xhtml' 找到匹配的导航案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JSF 页面之间导航时遇到问题.当您单击命令按钮时,我的大部分导航都会发生.命令按钮的动作返回一个字符串.

I am having trouble navigating between my JSF pages. Most of my navigation happens when you click a command button. The action of the command button returns a string.

我的登录页面是我的欢迎页面.这是在我的 web.xml 中:

My log in page is my welcome page. Here it is in my web.xml:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>faces/pages/index.xhtml</welcome-file>
</welcome-file-list>

在我浏览器的地址栏中,页面显示为:

In my browser's address bar, the page appears as:

http://localhost:8080/ui/faces/pages/index.xhtml

一旦认证发生,该函数返回这个字符串:

Once authentication happens, the function returns this String:

"/ui/faces/pages/home.xhtml"

我要导航到的文件位于:

The file I want to navigate to is located at:

pages/home.xhtml

但是当导航应该发生时,我得到这个错误:

However when navigation is supposed to happen, I get this error:

无法找到匹配的导航案例与 from-view-id '/pages/index.xhtml' for action '#{indexPageController.login()}' 结果为 '/ui/faces/pages/home.xhtml'

Unable to find matching navigation case with from-view-id '/pages/index.xhtml' for action '#{indexPageController.login()}' with outcome '/ui/faces/pages/home.xhtml'

谁能帮我理解正确导航到页面所需的相对路径?

Can anyone help me understand the relative path I need to correctly navigate to the page?

推荐答案

不应包含上下文路径 /uiFacesServlet 映射 /faces 在导航案例结果中.它应该只代表唯一的视图 ID,它基本上只是物理视图文件的绝对路径,相对于 web 内容根目录或相对于当前视图 ID.

You should not include the context path /ui nor the FacesServlet mapping /faces in the navigation case outcome. It should just represent the sole view ID, which is basically just the path to the physical view file absolute to the webcontent root or relative to the current view ID.

所以,绝对(从 / 开始)到 web 内容根:

So, absolute (starting with /) to the webcontent root:

/pages/home.xhtml

或相对于(不以 / 开头)与当前视图 ID(假设您在 /pages/index.xhtml 中):

Or relative (not starting with /) to the current view ID (assuming that you're in /pages/index.xhtml):

home.xhtml

请注意,不支持点斜杠 ./ 和双点斜杠 ../ 表示法.

Do note that dot-slash ./ and double-dot-slash ../ notations are not supported.

甚至没有文件扩展名;JSF 将暗示 Facelets 默认后缀,默认为 .xhtml 并且是 configureable by javax.faces.DEFAULT_SUFFIX 上下文参数:

Or even without file extension; JSF will imply the Facelets default suffix which defaults to .xhtml and is configureable by javax.faces.DEFAULT_SUFFIX context parameter:

/pages/home

home

如果您意识到上下文路径 /uiFacesServlet 映射 /faces/*not 无法从 webapp 内部控制!如果它们在外部发生更改,那么理论上您需要更改整个代码库中的所有导航案例结果并重建 webapp.这没有任何意义.因此,JSF 已经为您处理好了它们.

It makes after all also sense if you realize that the context path /ui and the FacesServlet mapping /faces/* are not controllable from inside the webapp on! If they ever change externally, then you'd theoretically need to change all navigation case outcomes in the entire codebase and rebuild the webapp. This would not make any sense. JSF takes thus already care of them for you.

这篇关于无法使用 from-view-id '/pages/index.xhtml' 找到匹配的导航案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆