The role of java @ResponseBody and @RequestBody

@RequestMapping(“url”)

url here write request is part of the path, the general method of acting on the Controller, as a request address mapping.

@ResponseBody

Acting on the method, which returns the process result is written directly to the HTTP response body, generally used in the asynchronous data acquired AJAX] {i.e. , @RequestMapping after use, the return value is typically resolved as the jump path, but with after @ResponseBody returns the result as the jump path can not be interpreted, but directly written in the HTTP response body. Such as asynchronous get json data, after adding @ResponseBody, it will return json data directly.

@RequestBody

It acts on the parameter list, for transmitting data over the front of a fixed format or formats json xml [package] and the like corresponding to a JavaBean, when used to package an object is the default configuration HttpMessageConverter parse, then parameter to the package.

 

 

Guess you like

Origin blog.csdn.net/qq_35462323/article/details/89879746