我試圖填補從MySQL database.First選擇框中的值(拆分值由逗號),我會讓我的數據庫設計之下,如何通過spilit逗號(,)從DB存儲選擇框值?
標準學科特徵
我學植物,動物,人類,自然
我數學整數,司,模塊
II科學BB,CC,DD,FF,GG
我的代碼,我想到目前爲止,
ListFeature.jsp
<select name="chapterdropdown" id="chapterdropdown"
onchange="selectchange()">
<%
Class.forName("com.mysql.jdbc.Driver");
Connection connection =DriverManager.getConnection("jdbc:mysql://localhost:3306/raptor1_5","root","");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("select * from contentselection where Standard='"+class1+"' and Subject='"+subject+"'");
while(rs.next())
{
String featvar = rs.getString("Features");
// here how to split the features by comma???
%>
<option><%=featvar%></option>
<% } %>
%>
</select>
有選擇feautures應當由一個在chapterdropdown選擇框顯示一個。
請有人解決我的問題。
http://stackoverflow.com/questions/10631715/splitting-a-comma-分隔線 – cy3er 2014-10-30 08:25:02