<td>
兴趣
</td>
<%
String favs = student.getStud_fav();//从数据库读取该记录的兴趣值,诸如:钢琴,书法,英语
String[] fav = favs.split(",");//按","分隔成多个字符串,以生成字符串数组
%>
<td>
<input type="checkbox" name="stud_fav" value="钢琴" <%for (int i = 0; i < fav.length; i++) {
if ("钢琴".equals(fav[i])) {
out.print("checked");
break;
}
}%> />
钢琴
<input type="checkbox" name="stud_fav" value="书法" <%for (int i = 0; i < fav.length; i++) {
if ("书法".equals(fav[i])) {
out.print("checked");
break;
}
}%>/>
书法
<input type="checkbox" name="stud_fav" value="英语" <%for (int i = 0; i < fav.length; i++) {
if ("英语".equals(fav[i])) {
out.print("checked");
break;
}
}%>/>
英语
</td>
转载于:https://www.cnblogs.com/beast-king/p/3851478.html