JSF - Welcome Page Redirect Example using Spring Boot

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.