We would like to create a \"WebService\" which return a list of specific objects. And we would like to call this webservice from another java program by apache http clients libr
The @ResponseBody
annotation tells Spring that we will be returning data in the response body rather than rendering a JSP.
When the @ResponseBody
annotation is used, Spring will return the data in a format that is acceptable to the client. That is, if the client request has a header to accept json and Jackson-Mapper is present in the classpath, then Spring will try to serialize the return value to JSON. If the request header indicates XML as acceptable (accept=application/xml
) and Jaxb is in the classpath and the return type is annotated with Jaxb annotation, Spring will try to marshall the return value to XML.