Advertisement
andersonalmada

Untitled

Jul 22nd, 2022
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package br.ufc.mandacaru5.controller;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5.  
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.ui.Model;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11.  
  12. @Controller
  13. public class WelcomeController {
  14.  
  15.     @Value("${welcome.message}")
  16.     private String message;
  17.  
  18.     private List<String> tasks = Arrays.asList("a", "b", "c", "d", "e", "f", "g");
  19.  
  20.     @GetMapping("/")
  21.     public String main(Model model) {
  22.         model.addAttribute("message", message);
  23.         model.addAttribute("tasks", tasks);
  24.         return "welcome"; // view
  25.     }
  26.  
  27.     @GetMapping("/hello")
  28.     public String mainWithParam(@RequestParam(name = "name") String name, Model model) {
  29.         model.addAttribute("message", name);
  30.         return "welcome"; // view
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement