如何编写多个FOR循环来显示2个变量?

时间:2017-07-13 11:34:52

标签: jsp for-loop

在我的代码中,我使用了两个for循环。我想在下拉列表中显示2个值数组。 “wpvalue”正确加载。但是“wpvalue1”加载了多次。如何更改我的代码?

while (rs1.next()) {
    String wplist = rs1.getString("wplist");
    String wplistname = rs1.getString("wplistname");

    String wplist1[] = wplist.split("/");
    String wplist2[] = wplistname.split("/");
    String wpvalue = "";
    String wpvalue1 = "";

    for (int p = 0; p < wplist1.length; p++) {
        for (int q = 0; q < wplist2.length; q++) {
            wpvalue = wplist1[p];
            wpvalue1 = wplist2[q];  
        }
        buffer2 = buffer2 + "<option value='" + wpvalue + "'>" + wpvalue1 + "</option>";
    }
    buffer2 = buffer2 + "</select>";
    response.getWriter().println(buffer2);
}

0 个答案:

没有答案