출처 : 점프 투 스프링부트
질문 리스트를 표시할 때 제목 옆에 답변의 개수를 표시해보자.
제목 옆에 나란히 출력되도록 하기 위해 <span> 태그를 사용했다.
<a th:href="@{|/question/detail/${question.id}|}" th:text="${question.subject}"></a>
<span class="text-danger small ms-2"
th:if="${#lists.size(question.answerList) > 0}" // 답변이 있는지 조사
th:text="${#lists.size(question.answerList)}"> // 답변 개수 표시
</span>
#lists.size(객체)
: 객체의 사이즈를 반환한다.답변을 1개 등록하니까 답변의 개수가 표시됐다.