Saturday, March 30, 2013

Prefix mvc for element mvc:annotation-driven is not bound

If you are planning to use <mvc:annotation-driven>  into your Spring MVC application, chances that you may be facing issue for "Prefix mvc for element mvc:annotation-driven is notbound " erorr. Root cause is that your bean definition XML doesn't have names-spaces mentioned below.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

    <context:component-scan base-package="com.anuj.spring.controller" />
    <mvc:annotation-driven />

Benefits of mvc-annotation-driven :
  • enable MVC java Config. To do same in Code instead of beans xml, you can add the annotation @EnableWebMvc to one of your @Configuration
  • enable support for formatting using @NumberFormat and @DateTimeFormat
  • enable support for validation using @Valid if JSR-303 provider present on classpath
  • HttpMessageConverter support for @RequestBody method parameters and @ResponseBody method return values from @RequestMapping or @ExceptionHandler methods. Also enable support for atom,rss,json,jaxb,String,resource,form,source convertors.
  • many more..

Author : Anuj Patel
Blog :

No comments:

Post a Comment