Home Spring Spring3.2 MVC Java Config or the MVC XML Namespace



MVC Java Config or the MVC XML Namespace
Posted on: February 1, 2013 at 12:00 AM
In this section, you will learn about two different way for configuring Spring MVC : MVC Java Config or the MVC XML Namespace.

MVC Java Config or the MVC XML Namespace

In this section, you will learn about two different way for configuring Spring MVC : MVC Java Config or the MVC XML Namespace.

For configuring Spring MVC, we have two additional ways : MVC Java config and the MVC XML namespace. These two ways provide the same type of configuration that overrides the DispatcherServlet defaults. You can choose either MVC Java config or MVC XML namespace according to your preference.

Append the annotation @EnableWebMvc to your @Configuration classes to enable the MVC Java config, as shown below :

@Configuration
@EnableWebMvc
public class MyWebAppConfig {

}

To accomplish the same, configure the element mvc:annotation-driven as shown below :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<mvc:annotation-driven />

</beans>

The above configuration registers a RequestMappingHandlerMapping, a RequestMappingHandlerAdapter, and an ExceptionHandlerExceptionResolver which provide support to annotated controller methods for handling request processing.

Related Tags for MVC Java Config or the MVC XML Namespace:


More Tutorials from this section

Ask Questions?    Discuss: MVC Java Config or the MVC XML Namespace  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.