如何在jsp页面上给下拉框绑值和塞值

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
</head>
<body>
<select name="buMen">
<%
  String[][] arraybu = {{"0","中部"},{"1","東部"},{"2","西部"}};
  for(int a=0;a<arraybu.length;a++){
 %>
    <option value=<%= arraybu[a][0] %>><%= arraybu[a][1] %></option>
    <%
    } 
     %>
</select>
<br>
test***********
<br>
<select name="buMen1">
<%
  String[][] arraybu1 = {{"0","中部"},{"1","東部"},{"2","西部"}};
  String strBu = "2";
  String selected = "";
  
  for(int a=0;a<arrayJigyou.length;a++){
  
  if(strBu.equals(arraybu1[a][0])){
      selected = "selected";
      }
 %>
    <option value="<%= arraybu1[a][0] %>" <%= selected %> ><%= arraybu1[a][1] %></option>
    <%
    } 
     %>
</select>
</body>
</html>

 

你可能感兴趣的:(html,jsp)