Common annotations for Controller
@Controller
Handling HTTP Requests
@RestController
Spring4 after the new annotation, the original return JSON data need @responsebody mate @controller, now merged into @restcontroller
@RequestMapping
Configure URL mapping, value configuration URL method path, methods configuration request method, example:@RequestMapping (value= "Hello", method = Requestmethod.get)
@PathVariable
Gets the data in the URL, the URL of the request: URL path/value , example: HTTP://LOCALHOST:8080/HI/1, the request method is relative to @requestparam concise
@RequestParam
Gets the value of the request parameter, @RequestParam (value = "id", required = False,defaultvalue = "1") value is the parameter name, required = False does not have to pass in (default is True), DefaultValue default value when parameters are not passed in
Url method of the request: URL path? key=value Example: http://localhost:8080/hi?id=1
@GetMapping and @postmapping
Combining annotations, @GetMapping is equivalent to @requestmapping (method = Requestmethod.get), @PostMapping is equivalent to @requestmapping (method = Requestmethod.post)
That is, @getmapping receives a GET request, @PostMapping receives a POST request
Spring Boot's entry controller common annotations