
데이터 목록 조회

요번 시간에는 데이터 목록을 조회하는 연습을 한다.

@GetMapping("/articles")
List<Article> articleEntityList = articleRepository.findAll();

articleEntityList로 받아온 데이터를 모델화 시킨다.

Model model
model.addAtribute("articleList", articleEntityList);

return "articles/index";

localhost:8080/articles/new 페이지에서 입력한 4개의 데이터들이 localhost:8080/articles 페이지에 목록으로 조회가 된 것을 확인 할 수 있다.

목록이 나오는 이유
articleList가 여러 데이터의 묶음이게 되면,
{{#articleList}} ... {{/articleList}} 안의 데이터가 반복문 처럼 데이터가 들어간다.
해당 변수가 데이터의 묶음 이면 안쪽의 데이터를 반복시켜준다.

References (참고 자료)
https://www.inflearn.com/course/%EA%B0%9C%EB%85%90%EC%8B%A4%EC%8A%B5-%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8-%EC%9E%85%EB%AC%B8