我有这段代码但是当else分支执行时,i
没有增加,我找不到原因......
while(rs.next()){
tableAktivityBuilder.append("<tr><td><input type=\"text\" class=\"rowAktivita\" value=\""+rs.getString("name")+"\"/></td><td>");
StringBuilder tmpBuilder = new StringBuilder("<select class=\"course\"><option value=\"-1\" type=\"\"></option>");
for(int i = 0; i < prurezove.length+odborne.length; i++){
int idKompetence = rs.getInt("id_kompetence");
if(rs.getString("typ_kompetence").equalsIgnoreCase("p") && i < prurezove.length){
if(idKompetence == prurezoveIds[i]){
tmpBuilder.append("<option value=\""+idKompetence+"\" type=\"p\" selected=\"selected\">"+prurezove[i]+"</option>");
}else{
tmpBuilder.append("<option value=\""+idKompetence+"\" type=\"p\">"+prurezove[i]+"</option>");
}
}else{
log.info("kompetence = o");
log.info("i = "+i);
int awa = prurezove.length+odborne.length;
log.info(""+awa);
if(idKompetence == odborneIds[x]){
tmpBuilder.append("<option value=\""+idKompetence+"\" type=\"o\" selected=\"selected\">"+odborne[x]+"</option>");
}else{
tmpBuilder.append("<option value=\""+idKompetence+"\" type=\"o\">"+odborne[x]+"</option>");
}
x++;
}
}
tableAktivityBuilder.append(tmpBuilder);
tableAktivityBuilder.append("</select></td><td>");
if(rs.getInt("cena") != 0){
tableAktivityBuilder.append(rs.getInt("cena"));
}
tableAktivityBuilder.append("</td></tr>");
}
日志输出
kompetence = o
i = 4
5
kompetence = o
i = 4
5
感谢您的帮助
答案 0 :(得分:3)
这只是你的out while循环执行两次,当i == 4然后退出时,你的内循环总是到达else {}。