@Controller
public class GreetingController {
@GetMapping("/greeting")
public String greeting(HttpServletRequest request, Model model) {
String name = request.getParameter("name");
model.addAttribute("name", name);
return "greeting";
}
}
What does the Model
do? Is this essentially the context variables that are passed to the "greeting.html" file? Is the only use of it addAttributes
that will then be passed to the HTML template? Where could I read more about what Model does and how it should be used?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…