Previously encountered json conversion type problems, understand the use of JSON, now learn the implementation of JSON.

Here are three reference links for learning

SpringMVC framework learning ten: SpringMVC handle JSON @requestBody and JSON @requestBody

  1. The first link goes into a lot of detail about the basic usage of JSON and the use and comparison of the three most commonly used JSON libraries (Gson, FastJson, Jackson).

  2. The second link describes how json and XML can be converted and how to switch output to JSON and XML.

    Springmvc common annotation tag details

    7, @responseBody: This annotation is used to write the object returned by Controller’s methods to the body data section of the Response object after being converted to the specified format via the appropriate HttpMessageConverter. When to use: when the data returned is not HTML tag pages, but some other format of data (such as JSON, XML, etc.);

  3. The third link also covers the implementation of JSON

conclusion

  1. The HttpMessageConverter interface in SpringMVC is responsible for converting the request information into an object, which is output as a response.
  2. Is it necessary to use RequestBody to pass JSON data? Json values with and without @repsonSeBody.
  3. - driven / > < MVC: an annotation. It is this configuration that causes Java objects to be automatically converted to JSON objects.Copy the code