A welcome-file-list allows you to specify a list of files that the web container will use for appending to a request for a URL that is not mapped to a web component.

The following example shows how to set a welcome file redirect for your JSF web application using Spring Boot and Maven.

General Project Setup

Tools used:

  • Spring Boot 1.5
  • PrimeFaces 6.1
  • JoinFaces 2.4
  • Selenium 3.8
  • Maven 3.5

We will start from a previous JSF Spring Boot Tutorial in which we created a greeting dialog based on a first and last name input form.

As we are running on Spring Boot we no longer have a web.xml in which we can specify a <welcome-file-list>.

A way to solve this is to extend the WebMvcConfigurerAdapter and then forward the default mapping to the target web page. In this example we will forward to helloworld.xhtml as shown below.

The WelcomePageRedirect class is annotated with @Configuration which indicates that the class can be used by the Spring IoC container as a source of bean definitions. In other words, we can specify the page redirect using Java-configuration instead of XML.

package com.codenotfound.primefaces.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

public class DefaultView extends WebMvcConfigurerAdapter {

  public void addViewControllers(ViewControllerRegistry registry) {


Let’s test above configuration by opening a command prompt. Execute following Maven command in order to start the JSF Hello World web application.

mvn spring-boot:run

The resulting console log should mention 'Started SpringPrimeFacesApplication' which indicates our web application is up and running.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 :: Spring Boot ::        (v1.5.7.RELEASE)

09:53:47.137 [main] INFO  c.c.p.SpringPrimeFacesApplication - Starting SpringPrimeFacesApplication on cnf-pc with PID 4748 (c:\codenotfound\code\jsf-primefaces\jsf-welcome-page-redirect\target\classes started by CodeNotFound in c:\codenotfound\code\jsf-primefaces\jsf-welcome-page-redirect)
09:53:47.141 [main] INFO  c.c.p.SpringPrimeFacesApplication - No active profile set, falling back to default profiles: default
09:53:51.586 [main] INFO  c.c.p.SpringPrimeFacesApplication - Started SpringPrimeFacesApplication in 4.756 seconds (JVM running for 8.77)

Open a web browser and enter following URL: http://localhost:9090/codenotfound/. The below web page should now be displayed.

jsf welcome page redirect

This means that the redirect was successfully applied as otherwise a 'Whitelabel Error Page' error would have been returned as shown below.

jsf welcome page redirect error

github mark If you would like to run the above code sample you can get the full source code here.

This concludes the short code sample on how to setup a JSF welcome file XHTML using Spring Boot.

Let us know if this example was helpful.

Leave a Comment