.tg {border-collapse:collapse;border-spacing:0;border-color:#999;}
.tg td{font-size:12px;padding:3px 13px 3px 13px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#999;color:#444;background-color:#fff}
.tg th{font-size:12px;font-weight:normal;padding:10px 5px 10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#999;color:#fff;background-color:#deb6db}
tr:hover td.tg-5hgy {
background-color: #777;
color: white;
}

<%
int total = dao.count();
ArrayList<VO> alist = dao.getMemberList();
int size = alist.size();
int size2 = size;
final int ROWSIZE = 20;
final int BLOCK = 5;
int pg = 1;
if(request.getParameter("pg")!=null) {
pg = Integer.parseInt(request.getParameter("pg"));
}
int end = (pg*ROWSIZE);
int allPage = 0;
int startPage = ((pg-1)/BLOCK*BLOCK)+1;
int endPage = ((pg-1)/BLOCK*BLOCK)+BLOCK;
allPage = (int)Math.ceil(total/(double)ROWSIZE);
if(endPage > allPage) {
endPage = allPage;
}
size2 -=end;
if(size2 < 0) {
end = size;
}
%>
<table class="tg" align="center">
<tr >
<th class="tg-031e">aaa</th>
<th class="tg-031e">bbb </th>
<th class="tg-031e">ccc</th>
</tr>
<%
if (total == 0) {
%>
<tr>
<td colspan="13" style="text-align:center">No have contents.</td>
</tr>
<%
} else {
for (int i = ROWSIZE * (pg - 1); i < end; i++) {
VO vo = alist.get(i);
int idx = vo.getNum();
String colorValue="#ffffff";
application.log(vo.getLevel()+"");
if(vo.getLevel() == 30 ) {
colorValue = "#d0c1d0";
}else{
colorValue = "#ffffff";
}%>
<style>
.tg .tg-5hgy{vertical-align: middle;background-color:<%=colorValue%>;text-align:center}
</style>
<tr>
<td class="tg-5hgy" id="num">
<%=vo.getNum();%>
</td>
<td class="tg-5hgy" id="level">
<%=vo.getLevel();%>
</td>
<td class="tg-5hgy" id="time">
<%=vo.getTime();%>
</td>
</tr>
</table>
&#13;
我想改变表格的行背景颜色,如果&#34; vo.getlevel()= = 30&#34; 然后转到&#34;#d0c1d0&#34;,但是我失败了... vo.getlevel()函数从mysql数据库获取值,我已经通过application.log()函数检查了值, 我该如何解决这个问题?
答案 0 :(得分:0)
我解决了..
例如,
我把&lt;%= colorValue%&gt;在每个所有td标签
<td class="tg-5hgy" id="num" style="background-color:<%=colorValue %>">
<td class="tg-5hgy" id="level" style="background-color:<%=colorValue %>">