Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
287 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...