Spring

Spring provides infrastructure support for creating Java applications.

Spring MVC

Spring MVC is a framework for creating Java web applications based on the popular Model-View-Controller architecture.

Spring Boot

Spring Boot is an extension of the Spring framework which provides an additional set of preconfigured tools.

Page Controller Architecture

The class diagram shows the main components of a Spring MVC application.

classDiagram
class Handler {
    +doGet
    +doPost
    ...
}

note for Handler "Front Controller: Dispatcher, Singleton"

class Command {
    <<abstract>>
    *process
}

class ConcretCommand1 {
    +process
}

note for ConcretCommand1 "Page Controller: handles requests uses model/view for logic/display"

class ConcretCommand2 {
    +process
}

Handler ..> Command
Command <|-- ConcretCommand1
Command <|-- ConcretCommand2

Spring MVC Flow

The front controller is realized by the DispatcherServlet. The servlet is initialized by the @SpringBootApplication annotation.

The command mapping is done by the @RequestMapping annotations in the controllers themselves. The dispatcher servlet (front controller) receives the request, looks up to correct page controller and forwards the request to it.

sequenceDiagram
    actor U as User
    participant FC as Dispatcher Servlet
    participant M as Request Mapping
    participant PC as Page Controller

    U->>FC: Request
    FC->>M: Lookup
    FC->>PC: Forward
    PC->>PC: Process (include Model and View)
    PC->>U: Response