In my Spring Boot application with packaging type as war, I am configuring Spring MVC. As I understand we don't have to configure Dispatcher Servlet manually. However, I old style of web.xml I used to configure Dispatcher Servlet and then I used to pass contextClass and contextConfigLocation as follows
<servlet>
<description>
</description>
<display-name>DispatcherServlet</display-name>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<description>contextClass</description>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<description>contextConfigLocation</description>
<param-name>contextConfigLocation</param-name>
<param-value>com.xxx.yyy.jdorderspringmvcweb.config.SpringMvcConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
I belive this was to indicate that SpringMvcConfig (my custom class with spring mvc configuration) is the configuration class for Spring MVC..
However, In spring boot if the Dispatcher Servlet is configured Automatically, how can I pass my custom class to the dispatcher Servlet?
In my Spring Boot application, my SpringMvcConfig class extends from WebMvcConfigurerAdapter and is annotated with @Configuration class.
Right in the configuration class which is annotated by @Configuration you could define your dispatcherServlet and pass init-parameter to it.
Another way would be to create a paramter map and then set parameter for registration bean. This stream shows how to do it.