From the course: Complete Guide to Spring MVC

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

HandlerFunction: Handler classes

HandlerFunction: Handler classes - Spring Tutorial

From the course: Complete Guide to Spring MVC

HandlerFunction: Handler classes

- [Instructor] Handler function, handler classes. We've learned about handler functions and we see how they differ from the annotation-based methods in Spring MVC. So now where do our handler functions go? They go inside of a handler class. Handler functions are used within handler classes to encapsulate that business logic, similar to how a controller and request mapping work in the traditional Spring MVC model. I've put together here a UML style diagram illustrating the relationship between a handler class, which I call HelloHandler and its handler functions which are handleGreeting and handleFarewell. And then we also have a router class, which we will call HelloRouter, which maps routes to these functions. The color-coded blocks indicate the following. The blue represent the classes, so HelloHandler and HelloRouter. The green represent individual handler functions within the handler class. And then the yellow blocks represent the routes defined in the router class that map HTTP…

Contents