我有简单的测试网络应用程序:首页 - index.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<html>
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
First page
<h:form>
<h:commandButton value="Go to Next page" action="next"/>
</h:form>
</h:body>
</html>
和下一页 - next.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<html>
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
Next page
<h:form>
<h:commandButton value="Go to First page" action="index"/>
</h:form>
</h:body>
</html>
当我运行我的应用程序时,我在浏览器上有那个 url:
http://localhost:8080/Test/
和 index.xhtml 作为第一页。
然后,当我单击“转到下一页”时,我有 url
http://localhost:8080/Test/index.xhtml
和 next.xhtml 页面。当我点击“转到第一页”页面更改(到 index.xhtml)但它的 url
http://localhost:8080/Test/next.xhtml
网页.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
我应该怎么做才能使我的应用程序的第一页有一个 URL,
http://localhost:8080/Test/index.xhtml
而不是
http://localhost:8080/Test/
?
我使用 Tomcat (TomEE)/7.0.37