Grokking Java Interview Questions
Vote

0% completed

​

Spring MVC Request Handling

The controller method below has one line, and it answers the request GET /orders/1001.

@GetMapping("/orders/{id}") public OrderSummary find(@PathVariable long id) { return orders.find(id); }

Spring MVC, the web part of the Spring Framework, did the rest of the work:

  • It chose this method from all the methods that handle requests.
  • It took 1001 from the path and converted the text to a long.
  • It wrote the returned object as JSON and set the content type.
  • It kept the default status 200, and it would have turned an exception into an error response.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content