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 Spring applications, the framework provides a way for us to access more information about the errors using the
ResponseStatusException class or the
With the annotations we learned in this lesson, we can now:
- Map HTTP requests to controllers and methods (
- Specify a path attribute to become a base path (
@RequestMappingat the class level)
- Declare request types using HTTP method annotations (
- Access request parameters in a method (
- Bind data using template variables (
- Fine-tune the status code returned by a method (
All of these annotations and
ResponseStatusException are imported from the
Great work and happy coding!
Look through SuperHeroController.java for some of the annotations we covered so far. Make sure you can describe what each one does before moving on.
Take this course for free