Java – how to add ArrayList in JSP

<html>
<html>
  <head>
    <Meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
  </head>
  <body>
<%=new Date() %>

<%
ArrayList al = new ArrayList();
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
%>

    <select>
      <option value="<%=al%>"></option>
    </select>
  </body>
</html>

This is my code. I want to download ArrayList in JSP. I don't know how to bind ArrayList or drop-down in HTML obtion. Please help me. I've tried a lot, but I can't do it

Solution

EDITED

Try this:

<%

ArrayList al = new ArrayList();
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");

%>

<select>
   <%  for(int i = 0; i < al.size(); i++) {
           String option = (String)al.get(i);
   %>
   <option value="<%= option %>"><%= option %></option>
   <% } %>
</select>
</body>
</html>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>