Unable to find matching navigation case with from-view-id '/pages/index.xhtml'

后端 未结 1 1414
陌清茗
陌清茗 2020-11-28 15:58

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.

<
相关标签:
1条回答
  • 2020-11-28 16:46

    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.

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

    /pages/home.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.

    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

    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.

    See also:

    • 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
    0 讨论(0)
提交回复
热议问题