How to fill in <form: select> with list <String>?
3 answers
You can do the following:
<form:select path="selectName"> <form:option value="0" label="Select an Option" /> <form:options items="${nameOfList}" /> </form:select>
Providing only the items attribute in the form: options tag, it should make a value and mark the value of each line in your list.
+8
protected Map referenceData(HttpServletRequest request) throws Exception { Map referenceData = new HashMap(); Map<String,String> country = new LinkedHashMap<String,String>(); country.put("US", "United Stated"); country.put("CHINA", "China"); country.put("SG", "Singapore"); country.put("MY", "Malaysia"); referenceData.put("countryList", country);
}
Then
<form:select path="country" items="${countryList}" />
0