How to avoid user access to .xhtml page in JSF?

后端 未结 5 1292
终归单人心
终归单人心 2020-12-06 02:05

I am new to JSF and writing first simply jsf web app.

URL with .jsf are mapping to .xhtml files in WebContent but why I can open .xhtml in web browser with all jsf t

5条回答
  •  醉酒成梦
    2020-12-06 02:22

    Apart from defining a to block direct access to .xhtml files as correctly answered by Stacker on this question, you could also just change the of the FacesServlet mapping from *.jsf to *.xhtml.

    
        facesServlet
        javax.faces.webapp.FacesServlet
        1
    
    
        facesServlet
        *.xhtml
    
    

    In JSF 1.x this used to end up in an infinite loop, but in JSF 2.x not anymore. So you could just call/link all pages as .xhtml without fiddling with different extensions. The only disadvantage is that you won't be able to display a "plain" XHTML file without invoking the FacesServlet, but such a page should be named .html anyway :)

提交回复
热议问题