我的项目是一个带有 spring mvc 的 portlet。我想即兴创作我的代码,所以我尝试使用<form:select>
而不是<select>
. 我想知道使用它需要进行哪些更改。选择的值应该返回给控制器。
jsp:
<form:form modelAttribute="drpdownValue" method="get" action="${URL_EOBLIST}">
<form:select path ="values">
<form:options items="${dropValues}"/>
</form:select>
</form:form>
型号类:
public class DropDownValues {
String values;
public String getValues() {
return values;
}
public void setValues(String values) {
this.values = values;
}
}
控制器:
@RequestMapping
public String initialize(RenderRequest renderRequest){
ModelMap modelMap=new ModelMap();
modelMap.addAttribute("drpdownValue",new DropDownValues());
return "formTable";//jsp name
}
@ModelAttribute("dropValues")
public List<String> getList(){
List<String> dropdown=new ArrayList<String>();
dropdown.add( "All Available");
dropdown.add( "Last 18 Months");
dropdown.add( "Last 12 Month");
dropdown.add( "Last 6 Months");
dropdown.add( "Last 3 Months");
return dropdown;
}