- list3 : Model
- SampleController
@RequestMapping("/sample01/list3")
public String list3(Model model) { //스프링이 구현 객체를 자동 주입
model.addAttribute("list", sampleDao.list())
.addAttribute("userName", "홍길동")
.addAttribute("address", "대구광역시");
return "sample01/sampleList3";
}
- sampleList3.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
${list}<br>
${userName}<br>
${address}
</body>
</html>

- list4 : ModelMap
- SampleController
@RequestMapping("/sample01/list4")
public String list4(ModelMap modelMap) { //구현체
modelMap.addAttribute("list", sampleDao.list())
.addAttribute("userName", "홍길동")
.addAttribute("address", "대구광역시");
return "sample01/sampleList4";
}
- sampleList4.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
${list}<br>
${userName}<br>
${address}
</body>
</html>
