This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes <mvc:annotation-driven/> Vs <context:annotation-config/> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "<mvc:annotation-driven/> Vs <context:annotation-config/>" Watch "<mvc:annotation-driven/> Vs <context:annotation-config/>" New topic
Author

<mvc:annotation-driven/> Vs <context:annotation-config/>

Rakesh Basani
Ranch Hand

Joined: Jun 04, 2012
Posts: 38
Hi friends..

According to my spring mvc knowledge <mvc:annotation-driven/> and <context:annotation-config/> these both are used to detect the annotations like @Controller,@ResponseBody,..

could anyone tell me the exact difference between these two tags in dispatcher-servlet.xml

Thanks in advance.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

<mvc:annotation-driven/> is a tag added in Spring 3.0 which does the following:

1. Configures the Spring 3 Type ConversionService (alternative to PropertyEditors)
2. Adds support for formatting Number fields with @NumberFormat
3. Adds support for formatting Date, Calendar, and Joda Time fields with @DateTimeFormat, if Joda Time is on the classpath
4. Adds support for validating @Controller inputs with @Valid, if a JSR-303 Provider is on the classpath
5. Adds support for support for reading and writing XML, if JAXB is on the classpath (HTTP message conversion with @RequestBody/@ResponseBody)
6. Adds support for reading and writing JSON, if Jackson is o n the classpath (along the same lines as #5)


<context:annotation-config/>
Looks for annotations on beans in the same application context it is defined and declares support for all the general annotations like @Autowired, @Resource, @Required, @PostConstruct etc etc.



[How To Ask Questions][Read before you PM me]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Also to point out.

<context:annotation-config> does NOT search for @Component, @Controller, etc.

<context:component-scan> DOES search for those @Component annotations, as well as the annotations that <context:annotation-config/> does.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Rakesh Basani
Ranch Hand

Joined: Jun 04, 2012
Posts: 38
thank you very much for your replies guys..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <mvc:annotation-driven/> Vs <context:annotation-config/>
 
Similar Threads
spring wont inject the entitymanager
Empty Ajax response with Spring 3 and jQuery
AOP Not working with Spring 3 MVC application
JPA, Spring and hibernate.ejb.interceptor
404 error while trying to test spring3 rest service