Build The Web Layer

Implementing the controller layer in Spring

Overview

The web/controller layer handles all the incoming REST requests to a service.

Steps

Follow the steps below to set up the request handler in the controller layer.

  1. Make a call to the method in the Service Layer and get the response back from it.

  2. Build the responseInfo.

  3. Build the final response to be returned to the client.

Sample request handler in controller layer

The controller class reflects the following content -

NOTE: At this point, your IDE must be showing a lot of errors, but do not worry, we will add all dependent layers as we progress through this guide, and the errors will go away.

The web layer is now set up.

Last updated

Was this helpful?