I'm not sure, but this may be more like what you're doing, but I'm not using a HashMap:
PHP Code:
@ModelAttribute("referenceData5")
public ReferenceData5 referenceData() {
final Collection<FormOption> formOptions = new ArrayList<FormOption>();
for (int i = 1; i < 6; i++) {
final String optionLabel = String.format("option%02d", i);
final FormOption formOption = new FormOption(optionLabel, i);
formOptions.add(formOption);
}
log.debug("formOptions: {}", formOptions);
final ReferenceData5 referenceData5 =
new ReferenceData5(formOptions);
return (referenceData5);
}
PHP Code:
public final class ReferenceData5 {
private final Collection<FormOption> formOptions;
...
public Collection<FormOption> getFormOptions() {
return (formOptions);
}
PHP Code:
public final class FormOption {
private final String selectLabel;
private final int selectValue;
public FormOption(final String _selectLabel, final int _selectValue) {
this.selectLabel = _selectLabel;
this.selectValue = _selectValue;
}
(usual getters and setters omitted)
PHP Code:
<form:select path="selectPath">
<form:option label="select an item" value="" />
<form:options
items="${referenceData5.formOptions}"
itemValue="selectValue"
itemLabel="selectLabel"
/>
</form:select>