O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring front controller

With Spring 5.0, there are three ways to configure DispatcherServlet programmatically, by implementing or extending any of the following three classes:

  • WebAppInitializer interface
  • AbstractDispatcherServletInitializer abstract class
  • AbstractAnnotationConfigDispatcherServletInitializer abstract class

We will use the AbstractDispatcherServletInitializer class, as it is the preferred approach for applications that use Java-based Spring configuration. It is preferred because it allows us to start a servlet application context, as well as a root application context.

We need to create the following class to configure DispatcherServlet:

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required