Now that we have DispatcherServlet defined in web.xml, we can go ahead and create our Spring context. Initially, we will create a very simple context without really defining anything specific:
<beans > <!-Schema Definition removed -->
<context:component-scan base-package="com.mastering.spring.springmvc"/>
<mvc:annotation-driven />
</beans>
We are defining a component scan for the com.mastering.spring.springmvc package so that all of the beans and controllers in this package are created and autowired.
Using <mvc:annotation-driven/> initializes support for a number of features that Spring MVC supports, such as the following:
- Request mapping
- Exception handling
- Data binding and validation
- Automatic conversion (for example, JSON) when the @RequestBody annotation is used
That's all of the setup we require in order to be able to set up a Spring MVC application. Now, we are ready to get started with the first flow.