@RequestMapping("/hello") public String sayHello(ModelMap model) { model.addAttribute("message", "Hello World!"); return "hello"; }
@Controller public class UserController { @Autowired private UserService userService; @RequestMapping("/users") public String getUsers(ModelMap model) { ListIn this example, the `ModelMap` object is used to add a list of users as an attribute and map it to the "users" view. This view can then iterate over the users attribute and display them in a table. The `org.springframework.ui ModelMap` package is part of the Spring Framework, specifically the Spring Web MVC module.users = userService.getUsers(); model.addAttribute("users", users); return "users"; } }