Pregunta

I'm currently having trouble exposing my JSF files from the browser URL. My project structure goes something like this:

<PROJECT_NAME>
--->WebContent
    --->index.xhtml
    --->subfolder1
        --->subjsf.xhtml
    --->subfolder2
        --->subjsf.xhtml
    --->subfolder3
        --->subjsf.xhtml

Here's my web.xml:

<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <display-name>PROJECT_NAME</display-name>
 <context-param>
  <param-name>org.richfaces.skin</param-name>
  <param-value>blueSky</param-value>
 </context-param>
 <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>*.xhtml</url-pattern>
 </servlet-mapping>

 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>/pages/*</url-pattern>
 </servlet-mapping>

 <welcome-file-list>
  <welcome-file>index.xhtml</welcome-file>
 </welcome-file-list>
</web-app>

My faces-config:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xi="http://www.w3.org/2001/XInclude"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
 <navigation-rule>
  <from-view-id>/index.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>subfolder1</from-outcome>
   <to-view-id>/subfolder1/subjsf.xhtml</to-view-id>
   <redirect/>
  </navigation-case>
 </navigation-rule>
 <application>
  <resource-bundle>
   <base-name>resources</base-name>
   <var>msgs</var>
  </resource-bundle>
 </application>
</faces-config>

Without using a redirect, it seems to work fine. But enabling redirect gives this error:

com.sun.faces.context.FacesFileNotFoundException: /subjsf.xhtml Not Found in ExternalContext as a Resource

When you access the URL directly something like this: <hostname>:<port>/PROJECT_NAME/subfolder1/subjsf.xhtml it also gave the same error above.

I want to enable the redirect for the URL to refresh and display the current page name. Also, is there a way to use implicit navigation with sub folders?

Really appreciated your help guys! Thank you in advance...

¿Fue útil?

Solución

As long as the content is not under WEB-INF, all the content should be directly accessible to the client.

Here are some tips to troubleshoot:

  • Is your WAR deployed successfully ?
  • Are you accessing the with the correct URL ?
  • Is context in your URL match the deployment ?
  • Are you bundling xhtml content correctly outside WEB-INF ?

Finally, you could go to the deployment directory, copy the WAR to a separate folder, deflate it and check if its content is as you expected.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top