Skip to content

Austronaut999/first-project-java-spring

Repository files navigation

First Spring Boot Project

This is my first Spring Boot web application.

Features

  • Greeting web page with dynamic name display
  • Thymeleaf template engine
  • Static image handling
  • REST controller

Technologies Used

  • Java 21
  • Spring Boot 3.x
  • Thymeleaf
  • Gradle
  • Embedded Tomcat

Project Structure

src/ ├── main/ │ ├── java/ │ │ └── pl/edu/vistula/firsprojectjavaspring/ │ │ ├── FirsProjectJavaSpringApplication.java │ │ └── controller/ │ │ └── HelloController.java │ └── resources/ │ ├── static/ │ │ └── vistula.png │ ├── templates/ │ │ └── greeting.html │ └── application.properties └── test/ └── java/ └── pl/edu/vistula/firsprojectjavaspring/ └── FirsProjectJavaSpringApplicationTests.java

Use Cases with HTTP Methods and Screenshots

Use Case 1: Home Page

  • HTTP Method: GET
  • URL: http://localhost:8080/
  • Description: Displays a text greeting message
  • Controller Code: Home Page

@GetMapping("/") @ResponseBody public String hello() { return "Hello Vistula, in my first Spring controller";

Endpoints

  • GET / - Main page
  • GET /greeting - Greeting page with name parameter

Use Case 2: Greeting Page with Default Name

HTTP Method: GET

URL: http://localhost:8080/greeting

Description: Displays greeting page with default name "World". Shows "Hello, World!" message and static image.

Parameters: No parameters required

Controller Code:

java @GetMapping("/greeting") public String greeting(@RequestParam(name = "name", required = false, defaultValue = "World") String name, Model model) { model.addAttribute("name", name); return "greeting"; } Screenshot: Greeting page

Use Case 3: Access Static Image

HTTP Method: GET

URL: http://localhost:8080/vistula.png

Description: Serves static image file from resources directory

Location: src/main/resources/static/vistula.png

Endpoints

GET / - Main page with text greeting

GET /greeting - Greeting page with name parameter

GET /vistula.png - Static image resource

About

- Greeting web page - Dynamic name display using Thymeleaf - Static image handling - REST controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published