0
votes

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
Why did you map *.html to FacesServlet when you don't want to treat it as a JSF template at all? Just remove it. The javax.faces.DEFAULT_SUFFIX already defaults to .xhtml, so you can also just remove it. - BalusC
I have xhtml-files in root-directory which should be treated by jsf and these are mapped by "html". But I have also files in "webapp/resources/templates" (which contains common html-files used by client side templating frameworks). Is there a way to exclude these "html"-mapping only for this folder ("webapp/resources/templates") ? All others should be mapped by "'html". - nimo23

1 Answers

0
votes

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

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