...
The web.xml
configuration file resides in the /WEB-INF/
directory of the (to be) deployed web application. It configures the web server part of the application. The web.xml
file can be used to define which file types may be requested by users, which directories can be accessed, and so on. With regards to JSF, the most important task of web.xml
is to tell the web server that there is such a thing as a Faces Servlet, and that URLs containing a certain pattern should be forwarded to that Faces Servlet. A minimal web.xml
could look like this:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/webapp_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>MyFaces Test Project</display-name> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> </web-app> |
...