如何在Jsp中添加arraylist [英] how to add arraylist in Jsp

查看:419
本文介绍了如何在Jsp中添加arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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>

这是我的代码,我想在Jsp的下拉列表中添加Arraylist,但我不知道如何在html中绑定arraylist或下拉列表,请帮助我,我已经尝试了很多但无法做到这一点.

This is my code i want to add Arraylist in drop down in Jsp I dont know how to Bind arraylist in html obtion or drop down please help me i have tried Much but unable to do 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>

这篇关于如何在Jsp中添加arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆