Springweb < form: Select > tag: defines a drop-down selection box or a list selection box

Example

public class NewBean{
  private List fanList;
  private String date;
  public String getDate(){
    return date;
  }
  public void setDate(String date){
    this.date=date;
  }
  public List getFanList(){
    return fanList;
  }
  public void setFanList(List fanList){
    this.fanList=fanList;
  }
}
<%@page contentType="text/html" import="java.util.*" pageEncoding="UTF-8"%>
  <!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
  <%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <%
       com.NewBean fanBean = new com.NewBean();
       List list = new ArrayList();  //定义一个List集合
       list.add("周一");  //为List集合添加数据
       list.add("周二");
       list.add("周三");
       list.add("周四");
       list.add("周五");
       fanBean.setFanList(list);  //把List集合保存到NewBean对象中
       request.setAttribute("command",fanBean);  //把NewBean对象保存到request中
       %>
      <form:form>
        计划完成日期在本周的:
        <form:select path="date" items="${command.fanList}"/><!--创建一个下拉列表-->
      </form:form>
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
分享
二维码
< <上一篇
下一篇>>