Using the Spring config mvc namespace

Namespace declaration

Spring 3.1

For Spring 3.1 use:


<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
</beans>
      

Message converters

As of Spring 3.1, you can specify custom object mappers for Jackson using the mvc:message-converter element.


  <mvc:annotation-driven>
      <mvc:message-converters>
          <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
              <property name="objectMapper" ref="customObjectMapper"/>
          </bean>
      </mvc:message-converters>
  </mvc:annotation-driven>

In the above context, there is a bean "customObjectMapper" which is a subclass of org.codehaus.jackson.map.ObjectMapper

Published: Monday, 21 May 2012