How to use .jsf extension in URLs?

前端 未结 3 1820
借酒劲吻你
借酒劲吻你 2020-12-31 13:04

I\'m developing a JSF 2 web application. For prestige purpouses I would like that every URL ends with .jsf extension. Now it ends with .xhtml. If I

3条回答
  •  无人及你
    2020-12-31 13:31

    The URL pattern of JSF pages is specified by of the FacesServlet in web.xml. As you mentioned that .xhtml works fine, you have apparently configured it as follows:

    
        Faces Servlet
        javax.faces.webapp.FacesServlet
    
    
        Faces Servlet
        *.xhtml      
    
    

    You need to change the accordingly to get the desired virtual URL extension.

    
        Faces Servlet
        javax.faces.webapp.FacesServlet
    
    
        Faces Servlet
        *.jsf      
    
    

    That's all you need to change in order to achieve the concrete functional requirement, really.

    However, this puts a security problem open. The enduser can now see the raw Facelets file source code when changing the extension in the URL back from .jsf to .xhtml. You can prevent this by adding the following security constraint to web.xml:

    
        Restrict access to Facelets source code.
        
            Facelets
            *.xhtml
        
        
    
    

提交回复
热议问题