inblog logo
|
devleekangho
    스프링부트

    [스프링 부트] 10. Mustache로 View 작성

    KangHo Lee's avatar
    KangHo Lee
    Nov 17, 2024
    [스프링 부트] 10. Mustache로 View 작성
    Contents
    1. Controller 소스 코드2. list.mustache3. 브라우저 화면

    1. Controller 소스 코드

    @GetMapping("/") public String list(Model model) { List<BoardResponse.DTO> boardList = boardService.게시글목록보기(); model.addAttribute("models", boardList); return "list"; }

    2. list.mustache

    <section> <table border="1"> <tr> <th>번호</th> <th>제목</th> <th></th> </tr> {{#models}} <tr> <td>{{id}}</td> <td>{{title}}</td> <td><a href="/board/{{id}}">상세보기</a></td> </tr> {{/models}} </table> </section>
    💡
    Mustache에서 {{#model}} 블록은 model이 컬렉션일 때 자동으로 반복문을 처리합니다.

    3. 브라우저 화면

    notion image
     
    Share article
    Contents
    1. Controller 소스 코드2. list.mustache3. 브라우저 화면

    devleekangho

    RSS·Powered by Inblog