私は試しましたが、これは私の試みです 。データベースからjspでコンボボックスに入力する必要があるのを助けてください
1-jsp ページ
<p class="ppp">Category</p>
<jsp:useBean id="categorys" class="database.conDB" scope="page"/>
<select name="categorys" size="1" style="width:196px; padding:5px;" >
<c:forEach var="categ" items="${categorys.categoryNames} ">
<option value="${categ}">${categ} </option>
</c:forEach>
</select>
=========== 2-これはconDBクラスの私の関数です
public String[] getCategory()
{
String query="SELECT category_name FROM books.category;";
Statement statement;
ResultSet resultSet ;
try{
statement=createConnection().createStatement();
resultSet=statement.executeQuery(query);
int count=0;
while(resultSet.next())
count++;
categoryNames=new String[count];
resultSet.first();
do{
categoryNames[count -1]=resultSet.getString("category_name");
count--;
}while(resultSet.next());
}catch(Exception e)
{e.printStackTrace();}
for (int i = categoryNames.length; i > 0; i--)
System.out.println(categoryNames[i - 1]);
return categoryNames;
}