SpringMVC of @ResponseBody comment Profile

About SpringMVC

SpringMVC also known as Spring Web MVC framework belong to the presentation layer. It is part of the Spring framework.

The core component class DispatherServlet

springMVC DispatherServlet around design, which handles all HTTP requests and responses.

@ResponseBody Profile

@ResponseBody annotation shows the results returned by the direct writing method of the HTTP response body (responseBody), generally used in the asynchronous data is acquired, usually after use @RequestMapping.

The return value is typically resolved as the jump path and, with the results returned @ResponseBody not be interpreted as the jump path, but directly written HTTP response body.

effect

The annotation for the Controller object returned by the method, by an appropriate body HttpMessageConverter conversion area after a specified data format, and writes the Response object.

When to use

Page returned html tag data is not, but some other data format (such as JSON, XML, etc.)

Handle custom type

To return a custom object JSON data type needs to be increased dependent jackson

Guess you like

Origin www.cnblogs.com/zxfei/p/11494143.html