serving common html without facelets/jsf-tags

I have the folder containing a client-side-html-template ("template.xhtml"). The folder resides in public folder (not in WEB_INF).

When saved the file with suffix "xhtml" and wrap the content with "<ui:composition", then client side (ajax) request can access.

However, when I save it to "template.html" and delete the "<ui:composition", then client ajax cannnot access this page (401).

My web.xml has this mapping:

<context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
<servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.html</url-pattern>
        </servlet-mapping>
<mime-mapping>
        <extension>xhtml</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <security-constraint>
        <display-name>Restrict raw XHTML Documents</display-name>
        <web-resource-collection>
            <web-resource-name>XHTML</web-resource-name>
            <url-pattern>*.xhtml</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>

How can I serve common "html-files" by client side ajax request without intercepting these files by jsf/facelets?

1 answer

  • answered 2018-01-11 20:59 nimo23

    Found a simple way without the need to change web.xml:

    I changed the static "html" files to "htm".