How can I redirect in JSF 2.0

后端 未结 1 1727
谎友^
谎友^ 2020-12-15 12:15

I want to redirect from a link in a JSF page, how can I do it?

In HTML I can use tag for this. But in JSF I use

1条回答
  •  遥遥无期
    2020-12-15 12:47

    Assuming that you'd like to redirect to some.xhtml which is placed in web root folder:

    1. You can just continue using plain HTML.

       go to some page
      

      For conditional rendering, just wrap it in an .


    2. Or use with implicit navigation.

       
      

      Note: no need to prepend context path nor to include FacesServlet mapping.


    3. Or use with ?faces-redirect=true.

       
      

      Note: no need to prepend context path nor to include FacesServlet mapping.


    4. Or use , but you need to specify context path.

       
      

    Redirecting to an external URL is already answered in this duplicate: Redirect to external URL in JSF.

    See also:

    • How to navigate in JSF? How to make URL reflect current page (and not previous one)
    • When should I use h:outputLink instead of h:commandLink?
    • JSF implicit vs. explicit navigation

    0 讨论(0)
提交回复
热议问题