-------------第一种-------------
界面代码
<select name='dId' id="dId" >
<c:forEach begin="0" end="${ls.size()-1}" var="order">
<option >${ls.get(order) }</option>
</c:forEach>
</select>
后台代码,
@RequestMapping("toLogin")
public ModelAndView toLogin() {
List<String> list=new ArrayList<String>();
list.add("王利虎");
list.add("张三");
list.add("李四");
ModelAndView mv = new ModelAndView("/login/login");
mv.addObject("ls",list);
return mv;
}
-------------第二种-------------
界面代码
<select name='dId' id="dId" > <c:forEach items="${ls}" var="item" > <option >${item }</option> </c:forEach></select>
后台代码
@RequestMapping("toLogin") public ModelAndView toLogin() { String[] array = {"1","2","3"}; ModelAndView mv = new ModelAndView("/login/login"); mv.addObject("ls",array); return mv; }