JSP 中 <c:forEach items="${list}" var="list"> 將迴圈變數命名為 list,與外層傳遞的 List 集合同名,導致 ${list.content} 實際訪問的是迴圈當前元素(若元素無 content 屬性則報錯),而非原本的集合。
修改 var 屬性為不衝突的名稱,例如 item 或 article:
<c:forEach items="${list}" var="article">
<tr>
<th><c:out value="${article.content}" /></th>
<th><c:out value="${article.name}" /></th>
<th><c:out value="${article.comment}" /></th>
<th><c:out value="${article.type}" /></th>
<th><a href="#">轉發</a></th>
</tr>
</c:forEach>
articleList)。article、user),提升可讀性。