18 lines
617 B
Java
18 lines
617 B
Java
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<String> hello(@RequestParam(required = false) String name) {
|
|
String message = (name != null && !name.isBlank())
|
|
? "Hello, " + name + "!"
|
|
: "Hello, World!";
|
|
return ResponseEntity.ok(message);
|
|
}
|
|
}
|