java.lang.NumberFormatException:对于输入字符串:“$ {status.index}”

时间:2014-10-04 01:31:06

标签: spring-mvc spring-portlet-mvc

我无法弄清楚这个问题的根本原因,它与以前版本的Spring,即Spring 3.2.X一起运行良好,但是使用最新版本,即Spring 4.1.0,它没有。不知道我做错了什么。

控制器:

  @ActionMapping(params = "action=view")
    public ModelAndView viewMessages(ActionRequest actionRequest,ActionResponse actionResponse,    Model model,@ModelAttribute("message") Message message, BindingResult result) throws Exception {
            HttpServletRequest servletRequest = PortletUtils.getHttpServletRequest(actionRequest);
            String sessionId = servletRequest.getSession().getId();           
            ArrayList<Message> messageList = getMessageList(sessionId);
            ModelAndView modelAndView = new ModelAndView("list");
            modelAndView.addObject("message", new Message());
           modelAndView.addObject("messageList",messageList);
            return modelAndView;
 } 

Form object:
    public class MessageForm implements Serializable {
    private static final long serialVersionUID = 1L;
    private long id;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    ArrayList<Message> messageList = new ArrayList<Message>();


    public ArrayList<Message> getMessageList() {
        return messageList;
    }

    public void setMessageList(ArrayList<Message> messageList) {
        this.messageList = messageList;
    }

    @Override
    public int hashCode() {
        return new Long(id).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (! (obj instanceof MessageForm)) {
            return false;
        }
        return this.id == ((MessageForm)obj).getId();
    }

list.jsp:

<form:form method="post" commandName="messageForm">
<portlet:defineObjects/>
<br/>

<c:if test="${empty messageForm.messageList}">No Message(s) found.</c:if>

<c:if test="${not empty messageForm.messageList}">
<table border="0" cellpadding="4" class="table table-striped table-borderless">
   <c:forEach items="${messageForm.messageList}" var="message" varStatus="status">
      <tr>          

        <td>
        <form:checkbox path='messageList[${status.index}].deleteFlag' value="${message.deleteFlag}"/>
        </td>

Error:
    Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'messageList[${status.index}]' of bean class [com.mtorg.messagecenter.domain.MessageForm]: Invalid index in property path 'messageList[${status.index}]'; nested exception is java.lang.NumberFormatException: For input string: "${status.index}"
    at org.springframework.beans.mtorg.getPropertyValue(mtorg.java:816)
    at org.springframework.beans.mtorg.getNestedBeanWrapper(mtorg.java:551)
    at org.springframework.beans.mtorg.getBeanWrapperForPropertyPath(mtorg.java:528)
    at org.springframework.beans.mtorg.getPropertyValue(mtorg.java:694)     

Jars:
aopalliance-1.0.jar
commons-fileupload-1.2.jar
commons-lang3-3.3.2.jar
commons-logging-1.1.3.jar
iText-5.0.2.jar
jstl-1.2.jar
log4j.jar
spring-aop-4.0.3.RELEASE.jar
spring-beans-4.0.3.RELEASE.jar
spring-context-4.0.3.RELEASE.jar
spring-context-support-4.0.3.RELEASE.jar
spring-core-4.0.3.RELEASE.jar
spring-expression-4.0.3.RELEASE.jar
spring-jdbc-4.0.3.RELEASE.jar
spring-orm-4.0.3.RELEASE.jar
spring-tx-4.0.3.RELEASE.jar
spring-web-4.0.3.RELEASE.jar
spring-webmvc-4.0.3.RELEASE.jar
spring-webmvc-portlet-4.0.3.RELEASE.jar
standard-1.1.2.jar

0 个答案:

没有答案