Advertisement
Guest User

AppEndpointController.java

a guest
Jul 1st, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package testapp;
  2.  
  3. import org.springframework.http.ResponseEntity;
  4. import org.springframework.web.bind.annotation.GetMapping;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestParam;
  7. import org.springframework.web.bind.annotation.RestController;
  8.  
  9. @RestController
  10. @RequestMapping("/app")
  11. public class AppEndpointController {
  12.  
  13.     @GetMapping
  14.     public ResponseEntity<String> getHello(
  15.         @RequestParam(value = "name", defaultValue = "") String name
  16.     ) {
  17.         return ResponseEntity
  18.             .status(200)
  19.             .body(name.isEmpty() ? "Hello" : "Hello, " + name + "!");
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement