我建议将
months成员变量更改为
Map如下形式:
private Map<Integer, String> months = new HashMap<Integer, String>();
然后,
Preparable在您的操作中实现该接口,并使用以下内容初始化地图:
public void prepare() throws Exception { String[] monthNames = new DateFormatSymbols().getMonths(); int i = 1; for (String monthName : monthNames) { months.put(i++, monthName); }}当然,您需要为添加一个getter和setter
months
另外,
private Integer month在您的操作中添加一个成员变量,该变量将保留用户选择的月份(同样,具有getter和setter方法)
然后,
s:select在您的JSP中使用以下标记:
<s:select label="Select Date of Month" name="month" headerKey="0" headerValue="--Select--" list="months"/>
因此,现在在您的
execute方法中,month成员变量应保存所选的月份。0应该没有选择,1应该是一月,依此类推。



