Navigation with Facelets template not working

后端 未结 1 579
旧巷少年郎
旧巷少年郎 2021-01-19 01:11

I\'m having some trouble with navigation when using Facelets.

I have my master template in /WEB-INF:


    
相关标签:
1条回答
  • 2021-01-19 02:06

    This means that the request URL (as appears in browser address bar) didn't match the URL pattern of the FacesServlet as definied in web.xml.

    Those links

    <a href="ram.xhtml">RAM</a>
    <a href="mobo.xhtml">Motherboard</a>
    <a href="video.xhtml">Video Card</a>
    

    expects the FacesServlet to be mapped on *.xhtml. But if it's mapped on for example *.jsf and changing it to *.xhtml is not an option for some reason (I however strongly recommend it), then you'd need to fix the links

    <a href="ram.jsf">RAM</a>
    <a href="mobo.jsf">Motherboard</a>
    <a href="video.jsf">Video Card</a>
    

    Or, better, just use <h:link>. It'll implicitly append the proper context path and FacesServlet mapping:

    <h:link value="RAM" outcome="ram" />
    <h:link value="Motherboard" outcome="mobo" />
    <h:link value="Video Card" outcome="video" />
    

    See also:

    • Communication in JSF 2.0 - Implicit navigation
    0 讨论(0)
提交回复
热议问题