简体   繁体   中英

web.xml for java server faces

I have just started learning about Java server faces and successfully tested out my first web app in JSF.

What puzzles me is that the navigation rules are specified in my faces-config.xml located in my WEB-INF folder and no where in my web.xml have i specified the location of my faces-config.xml file location.

So how does navigation take place ?

The JSF 1.2 specification (JSR 252) requires any JSF implementation to automatically load /WEB-INF/faces-config.xml at startup (if such a resource exists).

Quoting the section 10.4.2 Application Startup Behavior:

At application startup time, before any requests are processed, the JSF implementation must process zero or more application configuration resources, located according to the following algorithm:

  • Search for all resources named “META-INF/faces-config.xml” in the ServletContext resource paths for this web application, and load each as a JSF configuration resource (in reverse order of the order in which they are returned by getResources() on the current Thread's ContextClassLoader ).
  • Check for the existence of a context initialization parameter named javax.faces.CONFIG_FILES . If it exists, treat it as a comma-delimited list of context relative resource paths (starting with a “/”), and load each of the specfied resources.
  • Check for the existence of a web application configuration resource named “/WEB-INF/faces-config.xml” , and load it if the resource exists.

我相信web.xml定义的Faces servlet在Web应用程序启动时会加载faces-config.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM