【发布时间】:2011-09-01 14:59:13
【问题描述】:
当我在 Eclipse 中创建一个新项目时,它自动为我创建了一个 index.jsp 页面,我不希望起始页面是 .jsp,我希望它是一个 .xhtml 这就是我在 web.xml 中所做的:
<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">
<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>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>myStartPage.xhtml</welcome-file>
</welcome-file-list>
</web-app>
当我在 localhost 中运行项目时,上面的代码不允许我将页面 myStartPage.xhtml 作为第一页。
我应该如何修改它以使浏览器为我显示起始页。 我也不想使用任何 url 模式。这是强制性的吗?(我尝试删除该标签,但没有构建)。
【问题讨论】:
-
目前点击
http://server:port/appContext/时会显示什么?? -
当我尝试时:
http://localhost:8080/projectname/我得到 HTTP 状态 500javax.servlet.ServletException: The FacesServlet cannot have a url-pattern of /*.
标签: java eclipse jsf jsf-2 java-ee-6