Explicit Directory for JSF Template Files

I'm just getting into Seam / JSF development and looking for a way to search for XHTML template files from another place.

When setting up your JSF application, follow these steps:

<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>*.seam</url-pattern>
</servlet-mapping>

<context-param>
  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  <param-value>.xhtml</param-value>
</context-param>

when i enter the url like:

http://localhost/test.seam

The system loads the XHTML file into

<webapp>/test.xhtml

What I would like to configure is a prefix directory, so the file is viewed from

<webapp>/WEB-INF/views/test.xhtml

So, is there a way to achieve something like this:

<context-param>
  <param-name>javax.faces.DEFAULT_PREFIX</param-name>
  <param-value>/WEB-INF/views/</param-value>
</context-param>

Thank you for your help!

+3
source share
1 answer

. , , , /WEB-INF, . , . (ab) , . security-constraint url-pattern of *.xhtml auth-constraint web.xml :

<security-constraint>
    <display-name>Restrict direct access to XHTML files</display-name>
    <web-resource-collection>
        <web-resource-name>XHTML files</web-resource-name>
        <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint />
</security-constraint> 
+5

Source: https://habr.com/ru/post/1755695/


All Articles