@ResponseBody – Annotation that indicates a method return value should be bound to the web response body. (java doc see more information here)
So all it stats is that the method return type should be written straight to the HTTP response body (and not placed in a Model, or interpreted as a view name)
The presentation of the result within the body will be affected from few parameters.
I recommend reading the following section about Content Negotiation:
Spring will use is own Heuristics to figure out the requested response presentation:
The doc's summarize this in the following paragraph:
The available options are to check the file extension in the request
URI, the "Accept" header, a request parameter, as well as to fall back
on a default content type. By default, file extension in the request
URI is checked first and the "Accept" header is checked next.
You can use @RequestMapping to specify accept header.
<mvc:annotation-driven>
element has a content-negotiation-manager attribute.
By default it will work with Jackson 2 in version 4, so all you need is to add the following to your classpath
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.0</version>
</dependency>
On the client side you can consume the result with Ajax or using a direct url call.
The client side technology makes no different as long as it request the right content type.
If you get error 406 – your content type definition is conflicting with your request
You can look at the following example here