Program 2
Program 2
@GetMapping: it maps the HTTP GET requests on the specific handler method. it is
used to create a web services endpoint that fetches it is used instead of
using:@RequestMapping(method=ReqeustMethod.GET)
@PostMapping: it maps the HTTP POST requests on the specific handler method. it is
used to create a web service endpoint that creates it is used instead of
using:@RequestMapping(method=RequestMethod.POST)
@PutMapping: it maps the HTTP PUT requests on the specific handler method. it is
used to create a web service endpoint that creates or updates it is used instead of
using:@RequestMapping(method=RequestMethod.PUT)
@DeleteMapping: it maps the HTTP DELETE requests on the specific handler method. it
is used to create a web service endpoint that delete a resource. it is used instead
of using:@RequetMapping(method=RequestMethod.DELETE)
@PathMapping: it maps the HTTP PATCH requests on the specific handler method. it is
used instead of using: @RequestMapping(method=RequestMethod.PATCH)
@ResponseBody : it binds the method return value to the response body.it tells teh
Spring Boot Framework to serialize a return an object into JSON and XML format.
@pathVariable: it is used to extract the values from the uri. it is most suitable
for the Restful web service, where the url contains a path variabe. we can define
multiple @PathVariable in a method.
@RequestParam: it is used to extract the query parameters form the url. it is also
known as a query parameter. it is most suitable for web applications. it can
specify default values if the query parameter is not present in the url.
@RequestHeader: it is use to get the details about the HTTP request headers. We use
this annotation as a method parameter. The optional elements of the annotation are
name, required, value, defalutValue. for each detail in the header, we should
specify separate annotations. we can use it multiple time in a method.
@Required: it applies to the bean setter method. it indicates that the annotated
been must be populated at configuration time with the required property, else it
throws an exception BeaninitilizationException.
@Autowired: Spring provides annotation-based auto-wiring by providing @Autowired
annotation. it is used to autowire spring bean on setter methods, instance
variable, and constructor. when we use @Autowired annotation, the spring container
auto-wires the bean by matching data-type.
@Service: it is also used at class-level. it tells the spring that class contains
the business logic.