문제

This is my web.xml :

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

When I navigate to:

http://localhost:8080/LearningRoot/index.xhtml

I can see the page just fine, however when I navigate to:

http://localhost:8080/LearningRoot/

I get the error:

An Error Occurred:

The FacesServlet cannot have a url-pattern of /*. Please define a different url-pattern.

But why?

And this is my welcome file:

<welcome-file-list>
    <welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
도움이 되었습니까?

해결책

Because that would mean Everything that ever hits that context-root will be handled by FacesServlet, a requirement that FacesServlet already knows it couldn't possibly fulfill (It obviously doesn't make sense).

To achieve the mapping you intend, use a .xhtml mapping on FaceServlet

<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top