Hi, I am working on web applications.I have a query.How can I export data from database to JSON using spring,I am unable to understand.Please help me to resolve this.
Thank you very much in advance!!
Hi, I am working on web applications.I have a query.How can I export data from database to JSON using spring,I am unable to understand.Please help me to resolve this.
Thank you very much in advance!!
Try this code:
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody MyObj getJSON() {
MyObj obj = new MyObj();
return obj;
}
Put jackson
in your classpath and @ResponseBody
annotation in controller method handler.
Also enable mvc:annotation-driven
in your servlet config.
In this case MyObj will be serialized in JSON format.
Go through the following links for database and JSON examples.