2016-09-28 75 views
-2

font-end showing this wayjsp的下拉列表中選擇不來一個列表

這裏的代碼我想在一個列表

<%@page import="devesh.com.*,java.util.*"%> 
 
<html> 
 
<body> 
 
<form method="POST" action="OutBagAction.jsp"> 
 

 
<% 
 
ArrayList<Bag> list=BagWorker.getAllBag(); 
 

 

 

 
%> 
 
<center> 
 
<font face="Times new roman">ItemCode 
 
<% 
 
for(Bag ba:list) 
 
{ 
 
int itemcode=ba.getItemcode(); 
 
%> 
 
<select name ="itemCode"> 
 
<tr> 
 
<option><%= ba.getItemcode()%></option></tr> 
 
</select> 
 
<% } %> 
 
<br><br> 
 

 
<font face="Times new roman">SampleBy <input type="text" name="sampleBy"> 
 
<br><br> 
 
<font face="Times new roman">Color <input type="text" name="color"> 
 
<br><br> 
 
<font face="Times new roman">Quantity <input type="text" name="quantity"> 
 
<br><br> 
 
<font face="Time new roman">OutDate <input type="date" name="outDate"> 
 
<br><br> 
 
<input type="submit" value="Out Bag"></center> 
 

 
</body> 
 
</html>

我想在一個下拉列表下拉列表,列出我能爲那怎麼辦?

回答

1

在您的代碼中使用此代碼。假設你在JSP中獲得你的列表。

<select name="itemCode"> 
    <c:forEach items="${list}" var="value"> 
    <option value="${value}"> 
     ${value} 
    </option> 
    </c:forEach> 
    </select> 

當前您正在爲每個值都創建select是問題。您必須聲明一次選擇框並將所有值附加到它。

您可以通過在for-loop之外移動 <select name ="itemCode">來更正您的代碼。

+0

**非常感謝老兄** –

相關問題