All Projects
Backend

Hospital Patients — Spring Boot MVC + Thymeleaf

A focused Spring Boot MVC + Thymeleaf web app: a paginated patient table (3 per page), search by name via a derived query, delete with confirmation, and a shared decorated layout — seeded with a profile-guarded CommandLineRunner and tested with MockMvc on H2.

Thymeleaf
View engine
3 / page
Page size
MockMvc + H2
Tests
derived query
Search
Approach

Clean MVC baseline: controller + derived-query repository + decorated Thymeleaf views, MockMvc-tested

Tech Stack
Java 17Spring Boot 3.2Spring MVCThymeleaf + Layout DialectSpring Data JPALombokMySQLH2MockMvc
Keywords
Spring MVCThymeleafSpring Data JPAPaginationMockMvcLombokBootstrap
Deep Dive

A compact, well-tested Spring MVC + Thymeleaf patient app — the clean MVC baseline before security and validation are layered on.

Features

  • 📋 Paginated patient list (3 per page)
  • 🔎 Search by name via the derived query findByNomContains
  • 🗑️ Delete a patient (with confirmation)
  • 🎨 Shared layout (template1.html) applied through layout decoration

Architecture

web/         → PatientController (@Controller, pagination & search)
repository/  → PatientRepository (JpaRepository + query derivation)
entities/    → Patient (JPA entity, Lombok @Data/@Builder)
templates/   → patients.html decorated by template1.html

Engineering polish

  • Fixed Thymeleaf layout syntax: layout:decorate="template1"layout:decorate="~{template1}"
  • Moved data rows into <tbody>
  • Seed data via @Bean CommandLineRunner guarded with @Profile("!test")
  • Added an H2 test profile and MockMvc web tests

Runs on :8084/index with MySQL (or H2 for tests), Bootstrap 5 via WebJars.