什么是页面回显?
页面回显就是将后台的数据,返回到前端的页面上。
通过addAttributer将user的属性添加到model中去
@Controller
public class IndexController {
@RequestMapping("/user")
public String index(Model model){
User user = new User("用户一号");
user.setId(1);
model.addAttribute(user);
return "home";
}
}
然后就可以在前端页面中调用user的各种属性
网页输出: