Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Related Tutorials


 
 

Share on Google+Share on Google+

MVC Java Config or the MVC XML Namespace

Advertisement
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.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 1, 2013

Related Tutorials

Discuss: MVC Java Config or the MVC XML Namespace  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com