1. Automatically encapsulate the returned object as JSON
1). Add the following configuration to the spring configuration file:
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.json.GsonHttpMessageConverter"/> </mvc:message-converters> </mvc:annotation-driven>
2). Add @RestController or @ResponseBody annotation to the method to be converted to the Controller