Saturday, June 6, 2015

Servlet mapping doesn't care of physical file mapping

Although the servlet is defined in the following way:
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/pages/*</url-pattern>
  </servlet-mapping>
This does not means that I must have the physical path named /pages under the src/main/webapp. Maven doesn't care the path at all. As long as the XHTML file doesn't place under src/main/webapp, the error Not Found in ExternalContext as a Resource will be seen.

No comments: