This may happen while using Spring controllers like this:
- @RequestMapping(value = "/getbirds", method = RequestMethod.GET, produces = "application/json")
- public @ResponseBody
- List<Bird> getBirds(@RequestParam("term") String term) {
- List<Bird> lst;
- //..........
- return lst;
- }
@ResponseBody
annotations don't use normal view resolvers, they use their own.Put this in your dispatcher-servlet:- <bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
- <property name="messageConverters">
- <list>
- <ref bean="jacksonMessageConverter"/>
- </list>
- </property>
- </bean>
You may need to put this dependency in your pom.xml:
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.8.0</version>
- </dependency>
No comments:
Post a Comment