Spring MVC

Difference between tags annotation-config and component-scan used in web.xml

  • <context:annotation-config> helps to activate applied annotations in already registered beans in application context.
  • <context:component-scan> helps to register the beans in context, plus it also scans the annotations inside beans and activate them.

Difference between classes ContextLoaderListener & DispatcherServlet used in web.xml

  • ContextLoaderListener creates root application context. However, the beans in the root context cannot access the beans in child contexts (directly).
  • DispatcherServlet creates one child application context per servlet entry. In addition, the child contexts can access the beans defined in the root context.

Validation Support in Spring MVC

  • Using JSR-303 Annotations and any reference implementation e.g. Hibernate Validator
  • Using a custom implementation of org.springframework.validation.Validator interface

Advantages of MVC framework

  • Supports RESTful URLs.
  • Annotation-based configuration
  • Supports to plug with other MVC frameworks like Structs, Structs2, JSF, etc.
  • Flexible, in other words, supports different View types like JSP, Velocity, XML, PDF, Tiles, etc.
Scroll to Top