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

查看:232
本文介绍了无法从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:

无法找到动作'#{indexPageController.login()}'的具有from-view-id'/pages/index.xhtml'的匹配导航案例,结果为'/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.

因此,绝对是(以/开头)到Webcontent根目录:

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,其后缀为

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/*在Web应用程序内部是 不可控制的,那么这还是很有道理的!如果它们在外部发生了变化,那么从理论上讲,您需要在整个代码库中更改所有导航案例的结果,并重新构建Web应用程序.这没有任何意义.因此,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.

  • How to navigate in JSF? How to make URL reflect current page (and not previous one)
  • Difference between h:button and h:commandButton
  • When should I use h:outputLink instead of h:commandLink?
  • What URL to use to link / navigate to other JSF pages

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

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