Common annotations of Spring


Spring 2.5 introduces annotation processors

@Controller: used to identify the processor class;

@RequestMapping: Mapping rules from requests to handler function methods;

@RequestParam: The binding of request parameters to the method parameters of the processor function processing method;

@ModelAttribute: Binding of request parameters to command objects;

@SessionAttributes: Attributes used to declare session-level storage, placed on the handler class, usually listed

The names corresponding to model attributes (such as @ModelAttribute), these attributes will be transparently saved to the session;

@InitBinder: Custom data binding registration support for converting request parameters to the corresponding types of command object properties;

Spring 3.0 introduces RESTful architectural style support (supported by @PathVariable annotation and some other features), and introduces more annotation support

@CookieValue: Binding of cookie data to the method parameters of the processor function processing method;

@RequestHeader: The binding of the request header data to the method parameters of the processor function processing method;

@RequestBody: Binding of the body of the request (type conversion through HttpMessageConverter);

@ResponseBody: The return value of the processor function processing method is used as the response body (type conversion through HttpMessageConverter);

@ResponseStatus: Define the status code and reason returned by the handler function processing method/exception handler;

@ExceptionHandler: Annotated declaration of exception handler;

@PathVariable: Binding of the template variable part of the request URI to the method parameter of the handler function processing method

 

RestController in Spring4.x

I marked @RestController on the Controller, so that all methods equivalent to the Controller are marked with @ResponseBody

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326680603&siteId=291194637