java.lang.IllegalStateException:BindingResult既不是bean名称的普通目标对象,也不是userEditCommand'可用作请求属性

时间:2014-06-07 08:27:32

标签: java spring spring-mvc

@RequestMapping(value = "/user-edit-form", method = RequestMethod.POST)
public String userEditForm(@ModelAttribute("userEditCommand") UserEntity userEntity, BindingResult result, ModelAndView model, @RequestParam("userPhotoPath") MultipartFile file, HttpServletRequest request) throws IOException  {
    ((Model) model).addAttribute("user", new UserEntity());
    return "staff-user-profile";
    //return new ModelAndView("staff-user-profile","user",userEntity);
}

人员-用户profile.jsp

<form:form class="form-horizontal" action="staff-edit-form" commandName="userEditCommand" enctype="multipart/form-data" modelAttribute="userEditCommand">
   <form:label path="userFirstName" >First name:</form:label>
   <form:input path="userFirstName" value="${user.userFirstName }"/>

   <form:label path="userLastName" >Last name:</form:label>
   <form:input path="userLastName" value="${user.userLastName }"/>

 <form:label path="userAddress" >Address:</form:label>
   <form:textarea path="userAddress" cols="5" rows="3" value="${user.userAddress }"></form:textarea>

    <form:label path="userCity" >City:</form:label>
    <form:input path="userCity" value="${user.userCity }" />
     <form:label  path="userCountryId" >Country:</form:label>
    <form:select path="userCountryId" >
        <form:options items="${countryList}" />
   </form:select>

0 个答案:

没有答案