展示员工列表.
1、编写EmployeeController.
@Controller
public class EmployeeController {
@Autowired
private EmployeeDao employeeDao;
@RequestMapping("/emps")
public String list(Model model){
Collection<Employee> employees = employeeDao.getEmployees();
model.addAttribute("list", employees);
return "list";
}
}
2、提取公共页面.
标签的使用
th:fragment="name(var)" // 碎片
th:insert="~{commons::name(var)}" //引入碎片 insert 会在当前标签中插入内容 or th:replace="~{commons::name(var)}" // replace 会替换当前标签