package com.example.demo.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping("/hello") public ResponseEntity hello(@RequestParam(required = false) String name) { String message = (name != null && !name.isBlank()) ? "Hello, " + name + "!" : "Hello, World!"; return ResponseEntity.ok(message); } }