这是我的 web.xml :
<servlet-mapping>
<servlet-name>Faces Servlet</servlet>
<url-pattern>/*</url-pattern>
</servlet-mapping>
当我导航到:http://localhost:8080/LearningRoot/index.xhtml
我可以很好地看到页面,但是当我导航到:http://localhost:8080/LearningRoot/
我收到错误:An Error Occurred:
The FacesServlet cannot have a url-pattern of /*. Please define a different url-pattern.
但为什么?
这是我的欢迎文件:
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
最佳答案
因为那意味着 一切遇到上下文根的情况将由 FacesServlet 处理,FacesServlet 已经知道它不可能满足这一要求(这显然没有意义)。
要实现您想要的映射,请使用 .xhtml
FaceServlet 上的映射
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
关于jsf - 为什么 FacesServlet 不能有/*. 的 url-pattern?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15210420/