Spring MVC Json Response Example

JSON objects or Strings can be returned from Spring MVC controllers using some simple steps. Lets see some Spring MVC Json response examples in this post.

What is JSON?

JSON is a way of easily exchanging and storing data. JSON is all about key/value pairs.You can read more about JSON on Wiki.

The important points to remember for getting the JSON response are
1. Marking the mvc as annotation driven.
2. Adding Jackson dependency to pom.xml
3. Creating a model class that we need to send as JSON
4. Using the @ResponseBody in the Controller return value.
5. Using the produces = "application/json" in the @RequestMapping

1. Dispatcher Servlet

2. Jackson configuration in pom.xml

3. Employee Model

4. The Controller


Features of Spring MVC | Spring MVC Json Response with Example

Download Full Code – SpringMVCJsonGet.zip