What are the common annotations of SpringMVC in the interview and their usage

Commonly used such as @RequestMapping, @RequestBody, @ResponseBody, @PathVariable, @RequestParam, @GetMapping, @PostMapping, etc.


@RequestMapping: An annotation used to process request url mapping, which can be used on a class or method, and used on a class, indicating that all request methods of the class use the changed address as the parent path


 

 


@RequestBody: Annotation implementation accepts http json data and converts json to java objects (not much personal use)


@ResponseBody: The annotation implements converting the object returned by the controller into a json object to respond to the client

 


@PathVariable: Indicates that only a single parameter is accepted


@RequestParam: Used when the parameter name is different from the request parameter name. Can set default value

Guess you like

Origin blog.csdn.net/weixin_69218754/article/details/130779887