Key Concepts

Review core concepts you need to learn to master this subject

Mapping HTTP Requests

@RequestMapping("/sayhello") public String sayHello() { return "Hello, world"; }

The @RequestMapping annotation can be used at the method level or the class level to map an HTTP request to the appropriate controller method.

Responding to Requests with Spring
Lesson 1 of 1
  1. 1
    The Spring framework is an incredible resource to help us quickly build RESTful applications. The core functionality of these applications lies in their ability to receive requests, route them acco…
  2. 2
    The term REST stands for REpresentational State Transfer, and it describes the architectural technique used to facilitate communication between different systems via the web. Stateless requests are…
  3. 3
    We’ve discussed how to use @RequestMapping at the method level, now let’s discover how it can be used at the class level. When the @RequestMapping data annotation is used at the class level, the …
  4. 4
    In the Mapping Requests exercise, we discussed several parameters for the @RequestMapping data annotation. One of the arguments mentioned was the method argument. As a reminder, the method argument…
  5. 5
    In the previous exercise, we discussed the use of helper methods to specify the HTTP method being used. GET requests are used to retrieve information from the server, while POST, PUT, or DELETE req…
  6. 6
    In the previous exercise, we discussed the use of @RequestParam to pass data from query parameters to a method. @RequestParam is perfect to use when we want to filter the results or return several …
  7. 7
    So far we have seen how methods accept HTTP requests and how they pass data from those requests to method parameters. However, occasionally, the requests received will need to be more complex. For …
  8. 8
    Anytime an HTTP response is transmitted, a status code is included in the response. HTTP status codes are used to determine if the request was successful or if some type of error occurred and ever…
  9. 9
    We know HTTP status codes can be used to determine if a request was successfully processed or if an error was generated. However, we may want to fine-tune the HTTP response to give the user more in…
  10. 10
    In the previous exercise, we discussed the use of @ResponseStatus to apply custom HTTP status codes and reasons to an HTTP response. However, if an error is encountered, we can use ResponseStatusEx…
  11. 11
    Responding to HTTP requests is a complicated process. Thankfully, the Spring framework handles this complexity and allows us to easily use the functionality. Even when exceptions are thrown in Spri…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo