When i created a new project in eclipse, it automatically created for me an index.jsp page, i don't want the start page to be a .jsp, i want it to be a .xhtml This is what i did at the 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>
Th开发者_运维知识库e above code does not allow me to see the page myStartPage.xhtml as the first page when i run the project in localhost.
How should i modify this for the browser to display for me the start page. Also i dont want to use any url-pattern. Is that mandatory?(I tried removing that tag, but it did not build).
Try this servlet mapping:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
This works in Glassfish 3.
As far as I know always the index.jsp will be shown. You can add a redirect to the index.jsp:
<% response.sendRedirect("myStartPage.xhtml"); %>
But there might be a nicer solution.
精彩评论