That's because the FacesServlet
is mapped on an URL pattern of /faces/*
instead of *.xhtml
. The FacesServlet
is the one responsible for doing all the JSF works. All requests to JSF pages have to invoke the FacesServlet
. It will then parse the Facelets and JSF tags in the XML template and generate HTML code. Rightclick the blank page in your webbrowser and choose View Source. You'll see that all JSF tags are left unparsed. The webbrowser doesn't understand JSF tags, it only understands HTML.
In order to get rid of the /faces/*
path, you need to change the URL pattern of the FacesServlet
in web.xml
from
<url-pattern>/faces/*</url-pattern>
to
<url-pattern>*.xhtml</url-pattern>
This has the only (minor) caveat that you cannot serve plain .xhtml
files anymore without invoking the FacesServlet
, but those files should actually be served as .html
anyway ;)
See also:
- Sometimes I see JSF URL is *.jsf, sometimes *.xhtml and sometimes /faces/*. Why?