I tried to generate a json response earlier using spring-mvc (annotation) . After so may failure i find out some check point :
I need to add
<mvc:annotation-driven/>in my servelet mapper. although i don't know the reason.Then I need to add
@ResponseBodyannotation which should bound the return value as http response as the documentation says.- And I also need add some jacson dependency.
Did i missed something? Now i have bunch of questions
- why we have to add that in my servelet xml and how this whole process is working?
- As
jsonresponse is most commonly used when why spring needjacksondependency to generate json?
some days ago i was doing Struts2 generating json response there was much simple.
- Is there any way to do it more easily in spring-mvc .?