spring - welcome page after running dynamic web project -


this question has answer here:

i'm trying let welcome page displaying after running dynamic web project. when googling found lot of tutorials can't found solution. share:

  • the structure of project (i want page welcome.xhtml displayed default).
  • the file web.xml is:

<?xml version="1.0" encoding="utf-8"?>  <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"            xmlns="http://java.sun.com/xml/ns/javaee"            xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"           xsi:schemalocation="http://java.sun.com/xml/ns/javaee                                http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"            id="webapp_id"            version="3.0">  	<display-name>hispring</display-name>  	<welcome-file-list>  		<welcome-file>welcome.xhtml</welcome-file>  	</welcome-file-list>  	  	<context-param>  		<description>state saving method: 'client' or 'server' (=default). see jsf specification 2.5.2</description>  		<param-name>javax.faces.state_saving_method</param-name>  		<param-value>client</param-value>  	</context-param>  	  	<context-param>  		<param-name>javax.servlet.jsp.jstl.fmt.localizationcontext</param-name>  		<param-value>resources.application</param-value>  	</context-param>  	  	<listener>  		<listener-class>com.sun.faces.config.configurelistener</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>/faces/*</url-pattern>  	</servlet-mapping>  </web-app>

once clicking on hispring > run > run on server, should have url: http://localhost:8080/hispring/faces/welcome.xhtml. however, got http://localhost:8080/hispring/.

could please tell me missed; in advance.

according web.xml tomcat /welcome.xhtml , has no clue might in /faces/welcome.xhtml. url fine (if welcome.xhtml in /)

there might more elegant jsf version (i'm not of jsf guy) - possible solutions come mind be

  • map faces servlet *.xhtml remove /faces/ part path (you judge if proper jsf - comment if it's not , i'll remove part)
  • create separate explicit redirection, e.g. through (stupidly simple) index.html (of course, declare index.html welcome file) following sample:
<html>  <head><title>redirection</title>   <meta http-equiv="refresh" content="2;url=/faces/">   <!-- 2 means 2 seconds delay. change -->  </head>  <body>   <p>redirecting application. <a href="/faces/">click here if doesn't work</a></p>  </body> </html> 

Comments