I'm using JSF for my project and I want to separate .xhtml files in subfolders.
My current directory structure is as follows:
webapp/
resources/
WEB-INF/ (beans.xml, web.xml)
faces/ (test.xhtml)
login.xhtml
register.xhtml
...
But when I try to access [PROJECT]/faces/test.xhtml it never works. I get a 404 Not Found error with the following description: "/test.xhtml Not Found in ExternalContext as a Resource."
The stackOverflow question: Organizing .xhtml files in subfolders has exactly the same problem and still hasn't received any helpful answers regarding this problem.
As an alternative I can also ofcourse use container managed authentication, but I refuse to do so, because it should be possible to just separate views in different subfolders, right?
web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Project</display-name>
<welcome-file-list>
<welcome-file>timeline.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
Okayy I solved my problem by removing the following line of code:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
I don't know why that was a problem though.