JSF resources also need to be served by the FacesServlet
. It's the one responsible for locating the right file in /resources
folder and returing it along with proper caching headers. If you remove the .xhtml
extension (or /faces
path) from the resource URL, then the URL won't match the URL pattern of FacesServlet
anymore and thus the FacesServlet
wouldn't be invoked and wouldn't be able to do its job of serving the resource. You would only get a 404 Not Found error back, because the "raw" resource URLs do not match the public webcontent folder structure.
UnmappedResourceHandler
makes use of the fact that JSF resource URLs have a common prefix path /javax.faces.resource
, as identified by ResourceHandler.RESOURCE_IDENTIFIER
. So, in order to invoke the FacesServlet
anyway, even without the .xhtml
extension (or /faces
path), you just need to add the /javax.faces.resource/*
URL pattern to the mapping.
The CDNResourceHandler
doesn't need a change in the mapping as it doesn't produce JSF resource URLs anyway, but true CDN URLs like ones pointing to jQuery or Google CDN hosts. Those URLs wouldn't (need to) hit the FacesServlet
anyway.
The CombinedResourceHandler
just produces default JSF resource URLs, with .xhtml
extension (or /faces
path). It only uses a special library
name of omnifaces.combined
, so that the CombinedResourceHandler
can identify them.