Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package testapp;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- @RequestMapping("/app")
- public class AppEndpointController {
- @GetMapping
- public ResponseEntity<String> getHello(
- @RequestParam(value = "name", defaultValue = "") String name
- ) {
- return ResponseEntity
- .status(200)
- .body(name.isEmpty() ? "Hello" : "Hello, " + name + "!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement