ModelMap model = new ModelMap(); model.put("message", "Hello World");
ModelMap model = new ModelMap(); ListThis example creates a new ModelMap instance and adds a List of String values with the key "names". The values can be accessed within the view layer by using the same key. The package library for the ModelMap class is org.springframework.ui.names = new ArrayList<>(); names.add("Alice"); names.add("Bob"); model.put("names", names);