ERROR - JSP / JSTL - javax.servlet.jsp.JspException: Type [java.lang.Integer] is not valid for option items

Error

javax.servlet.jsp.JspException: Type [java.lang.Integer] is not valid for option items at org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(OptionWriter.java:143) at org.springframework.web.servlet.tags.form.OptionsTag.writeTagContent(OptionsTag.java:155) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80) at

Sample Code
<form:options items="${command.getQuantity()}" itemValue="" itemLabel="" />

where getQuantity returns an Integer value.

Cause


items should hold collection of objects and Integer Type is not permitted.

Resolution


Have a method that returns collection of quantities.

<form:options items="${command.getCollectionOfQuantities()}" itemValue="" itemLabel="" />