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

Creating a Spring application context and configuring a ViewResolver

In Spring 5.0, to create a Spring application context and to configure a ViewResolver using Java configuration, we need to add the following code in the class:

@Configuration@EnableWebMvc@ComponentScan({ "com.packt.springhighperformance.ch4.bankingapp.controller"})public class SpringMvcWebConfig implements WebMvcConfigurer {  @Bean  public InternalResourceViewResolver resolver() {    InternalResourceViewResolver resolver = new     InternalResourceViewResolver();    resolver.setPrefix("/WEB-INF/views/");    resolver.setSuffix(".jsp");    return resolver;  }}

In the preceding code, we created a class, SpringMvcWebConfig, implementing a WebMvcConfigurer interface, which provides options for ...

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