How albertoortizortega/practica-ems works
Main Components
• Spring Boot Application: Represented by the Application.java class, it is the entry-point containing the main() method. This component bootstraps the application and uses an embedded Tomcat servlet container.
• Web Controller: The GreetingController.java class is annotated with @Controller. It handles HTTP GET requests (mapped to /greeting) and processes the “name” parameter to render a response.
• View Templates: Thymeleaf-based HTML templates (greeting.html under “src/main/resources/templates”) are used to render dynamic HTML content.
• Static Resources: Files under “src/main/resources/static” (including index.html and CSS files) serve as static content, with the index.html acting as the home page.
• Build/Configuration: The pom.xml defines project dependencies and build configuration (using Maven), while resource directories are organized to support Spring Boot’s auto-configuration.
Relationships and Interactions
• The Application component initializes the Spring Boot runtime; upon startup, it registers the DispatcherServlet.
• The DispatcherServlet routes incoming HTTP requests to the appropriate controller (GreetingController in this case) based on URL mapping.
• Within GreetingController, the incoming request’s “name” parameter is bound via @RequestParam and the model is populated.
• The controller returns the name of the view (“greeting”), which is handled by Thymeleaf to merge the model data into greeting.html.
• For the root URL ("/"), the static index.html is automatically served from the /static directory.
• Data flow flows from the HTTP request → DispatcherServlet → Controller → Model → View Renderer → HTTP response.
Architectural Patterns and Design Principles
• MVC Pattern: The separation of concerns is evident with controllers handling user input, models carrying data, and views handling presentation.
• Embedded Server Concept: Utilization of an embedded Tomcat server is a key aspect of Spring Boot’s design.
• Convention over Configuration: Spring Boot auto-configures components (e.g., static resource handling, view resolution) based on directory structures and annotations.
Technologies, Frameworks, and Libraries
• Spring Boot and Spring MVC for application structure and web handling.
• Thymeleaf as the server-side templating engine.
• Maven for project build and dependency management.
• Annotations like @Controller, @GetMapping, and @RequestParam are central to the design.
• Use clear labels for each component:
• “Spring Boot Application (Application.java)”
• “DispatcherServlet” (as a middleware component handling routing)
• “GreetingController” (handling /greeting requests)
• “Thymeleaf Template Engine / greeting.html”
• “Static Resources (index.html, CSS)”
• Optionally, note “Maven Build (pom.xml)” as the build and dependency management component.
• From “HTTP Request” to “Embedded Tomcat / DispatcherServlet”.
• From “DispatcherServlet” to “GreetingController”.
• From “GreetingController” to “Thymeleaf Template (greeting.html)” or to the “Static Resource” if it's the welcome page.
• Finally, indicate the HTTP response going back to the client.