我不是高手这个手工添加一下不就行了吗?
<html:option value="1">一月</html:option>
...

解决方案 »

  1.   

    像这样固定的tag,我建议,还是自己写一个taglib比较好。不要用struts的select/option,以后画面一多了,维护起来也麻烦。
      

  2.   

    Renders a set of HTML <option> elements, representing possible choices for a <select> element. This tag can be used multiple times within a single <html:select> element, either in conjunction with or instead of one or more <html:option> or <html:optionsCollection> elements.This tag operates in one of two major modes, depending on whether or not the collection attribute is specified. If the collection attribute is included, the following rules apply:The collection attribute is interpreted as the name of a JSP bean, in some scope, that itself represents a collection of individual beans, one per option value to be rendered. 
    The property attribute is interpreted as the name of a property of the individual beans included in the collection, and is used to retrieve the value that will be returned to the server if this option is selected. 
    The labelProperty attribute is interpreted as the name of a property of the individual beans included in the collection, and is used to retrieve the label that will be displayed to the user for this option. If the labelProperty attribute is not specified, the property named by the property attribute will be used to select both the value returned to the server and the label displayed to the user for this option. 
    If the collection attribute is not specified, the rules described in the remainder of this section apply.The collection of values actually selected depends on the presence or absence of the name and property attributes. The following combinations are allowed:Only name is specified - The value of this attribute is the name of a JSP bean in some scope that is the collection. 
    Only property is specified - The value of this attribute is the name of a property of the ActionForm bean associated with our form, which will return the collection. 
    Both name and property are specified - The value of the name attribute identifies a JSP bean in some scope. The value of the property attribute is the name of some property of that bean which will return the collection. 
    The collection of labels displayed to the user can be the same as the option values themselves, or can be different, depending on the presence or absence of the labelName and labelProperty attributes. If this feature is used, the collection of labels must contain the same number of elements as the corresponding collection of values. The following combinations are allowed:Neither labelName nor labelProperty is specified - The labels will be the same as the option values themselves. 
    Only labelName is specified - The value of this attribute is the name of a JSP bean in some scope that is the collection. 
    Only labelProperty is specified - The value of this attribute is the name of a property of the ActionForm bean associated with our form, which will return the collection. 
    Both labelName and labelProperty are specified - The value of the labelName attribute identifies a JSP bean in some scope. The value of the labelProperty attribute is the name of some property of that bean which will return the collection. 
    Note that this tag does not support a styleId attribute, as it would have to apply the value to all the option elements created by this element, which would mean that more than one id element might have the same value, which the HTML specification says is illegal.
     
    Attribute Name Description 
    collection Name of the JSP bean (in some scope) which is itself a Collection of other beans, each of which has properties named by the "property" and "labelProperty" attributes that are used to retrieve the value and label for each option, respectively. (RT EXPR)  
    filter Set to false if you do NOT want the option labels filtered for sensitive characters in HTML. By default, such values are filtered. (RT EXPR)  
    labelName Name of the JSP bean (in some scope) containing the collection of labels to be displayed to the user for these options. (RT EXPR)  
    labelProperty Property of the form bean, or the bean specified by the labelName attribute, that will return the collection of labels to be displayed to the user for these options. (RT EXPR)  
    name Name of the JSP bean (in some scope) containing the collection of values to be returned to the server for these options. If not specified, the form bean associated with our form is assumed. (RT EXPR)  
    property Property of the form bean, or the bean specified by the name attribute, that will return the collection of values to returned to the server for these options. (RT EXPR)  
     
      

  3.   

    这个项目需要用struts的,月份可以写12个,那选单是天呢?我要再写31个?语法的书我有,就是看不太明白,谁有实例给我发一个谢谢。
      

  4.   

    <html:select property="department_id">
    <option value=""></option>
    <html:optionsCollection name="users1"/>
        </html:select>public class DepatmentAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception ,SQLException, NamingException{
    Statement statement = null;
    List list1 = new ArrayList(); DepartmentForm df = (DepartmentForm)form; 
    Context ctx = (Context) new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/OracleDB");
    Connection connection1 = ds.getConnection();
    statement = connection1.createStatement();
    String sql = "select DEPARTMENT_ID,DEPARTMENT_NAME from TEST_DEPARTMENT";
    ResultSet rs = statement.executeQuery(sql);
    while (rs.next()) {
    list1.add(new LabelValueBean((String) rs
                        .getString("DEPARTMENT_NAME"), (String) rs
                        .getString("DEPARTMENT_ID")));
    }
    if (statement != null) {
    statement.close();
    connection1.close();
    }
    df.setList1(list1);
    request.getSession().setAttribute("users1", list1);
    return mapping.findForward("check");
    }
    }上面是从数据库中检索结果,你可以直接把月份放到list中
      

  5.   

    构造月份下拉框:
    <%
    String str_month="<option value=''>请选择</option>";
    for(int i=1;i<=12;i++)
    {
    str_month+="<option value=\""+i+"\">"+i+"</option> ";
    }
    %>
    <select name="MONTH"><%=str_month%>
             </select>构造日下拉框:<select name="fromdate">
                  <option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option>
                  <option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option>
                  <option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option>
                  <option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option>
                  <option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option>
                  <option value="26">26</option><option value="27">27</option><option value="28">28</option>
             </select>