Type [java.lang.String] is not valid for option items upon migrating from Spring 3.0.6 to 3.2.3

余生长醉 提交于 2019-12-23 04:45:36

问题


I am working on migrating a dynamic web project from Spring 3.0.6 to 3.2.3. Prior to this migration, we had no issue with our dropdowns. However, after migrating, we get the following error:

Exception created : com.ibm.websphere.servlet.error.ServletErrorReport: javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items

I've removed all the code to isolate the issue, so below is the relevant code. Please let me know if any further information is needed. The thing that puzzles me is that the List isn't even String based. I realize that the JSP will treat the values as String for the options, but my understanding is that there is a built-in PropertyEditor that would do this translation.

Controller:

@RequestMapping("/reports-menu.html")
public String showReportsHome(@ModelAttribute("reportForm")ReportForm reportForm, Model model, HttpSession session, HttpServletResponse response, HttpServletRequest request) {

    List<Integer> intList = new ArrayList<Integer>();
    intList.add(1);
    intList.add(2);
    intList.add(3);

    model.addAttribute("intList", intList);


    return "reports-home-int";
}

JSP:

<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="/WEB-INF/tld/sbp.tld" prefix="sbp" %>

<form:form name="report_form" method="POST" modelAttribute="reportForm" action="reports-menu.html" id="report_form">
<form:hidden path="download" id="form_download"/>
<form:hidden path="sortDirection" />
<form:hidden path="sortBy"/>
<input type="hidden" name="reset"/>
<div align="left">
<table border="0">
<tr>
<td><b>Mailer Name</b></td>
<td>
<form:select path="mailerCond">
<form:options items="${intList}" />
</form:select>
</td>               
</tr>
</table>
</div>
</form:form>

来源:https://stackoverflow.com/questions/25772469/type-java-lang-string-is-not-valid-for-option-items-upon-migrating-from-spring

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!