Torben Vesterager
Torben Vesterager

Reputation: 508

Why doesn't Spring 3.1 automatically use Jackson when POST header Content-Type=application/json?

No configuration or annotation is needed when setting request header "Accept=application/json"

Upvotes: 0

Views: 618

Answers (3)

Eruvanos
Eruvanos

Reputation: 689

In my situation, I fixed it with using another source for Jackson, because @RequestBody does not converted to the type I expect.

Instead of Codehause Jackson, I use now fasterxml:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.3.3</version>
</dependency>

Upvotes: 0

Torben Vesterager
Torben Vesterager

Reputation: 508

It does work automatically - in my controller I used an incorrect annotation - I used @RequestParam - it must be @RequestBody

Upvotes: 0

itzg
itzg

Reputation: 1111

It's almost automatic. Referring to

http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/mvc.html#mvc-config-enable

Jackson is automatically selected and registered when it is in the classpath (i.e. pom.xml) and you use mvc:annotation-driven in your context config.

Upvotes: 1

Related Questions