ResponseBody response json data-SpringMVC (eight)

  This annotation is used to convert the object returned by the method of the Controller to the data in the specified format through the HttpMessageConverter interface, such as json, xml, etc., and respond to the client through the Response.

  SpringMVC uses MappingJacksonHttpMessageConverter to convert json data by default. You need to add Jackson's package. It cannot be used under 2.7.0.

@Controller ("jsonController" )
 public  class JsonController {
     / ** 
    * Test response json data 
    * / 
    @RequestMapping ( "/ testResponseJson" )
     public @ResponseBody Account testResponseJson (@RequestBody Account account) { 
        System.out.println ( "Asynchronous request : "+ Account);
         return account; 
    } 
}

 

Guess you like

Origin www.cnblogs.com/guancangtingbai/p/12679210.html