(forEachループによる)目的は、テーブル内の3行ごとに背景色を設定することです。以下の私のコードは機能しません。表はすべてのデータが含まれている状態で正しく返されていますが、色は設定されていません。
<c:forEach var="coffee" items="${collection}">
<tr class="${status.count % 3 == 0 ? 'even' : 'oneven'}"
${status.count % 3 == 0 ? 'even' : 'oneven'} >
<td> ${coffee.brand} </td>
<td> ${coffee.type} </td>
<td> ${coffee.country} </td>
</tr>
</c:forEach>
私のCSSクラス
tr.even { background: red; }
tr.odd { background: green; }
ご協力ありがとうございました。
私は私の答えを見つけました:
<h2>tabel with changing colors</h2>
<table border=1>
<tr>
<th>Brand</th>
<th>type</th>
<th>Country</th>
</tr>
<c:forEach var="coffees" items="${collection}" varStatus="status">
<tr class="${status.count % 3 == 0 ? 'even' : 'odd'}"
${status.count % 3 == 0 ? 'even' : 'odd'}>
<td>${coffees.brand}</td>
<td>${coffees.type}</td>
<td>${coffees.country}</td>
</tr>
</c:forEach>
</table>