spring mvc - Neither BindingResult Nor Plain Target Object For Bean Name ‘Xxx’ Available As Request Attribute -


i getting error, while trying configure spring controllers. sure have name correctly matching , still gives me error. here controller class. input , output page same. please me

"neither bindingresult nor plain target object bean name 'userform' available request attribute"

@controller @sessionattributes public class usercontroller {      protected log logger = logfactory.getlog(getclass());      @autowired     userservice userservice;      @requestmapping(value="/userlist")     public modelandview getuserlist(){          list<user> userlist = userservice.getuserlist();                  return new modelandview("userlist", "userlist", userlist);           }      @requestmapping(value="/finduser")     public modelandview finduser(@modelattribute("user") user user,                                  bindingresult result){           list<user> userresultslist = null;          //model.addattribute("user", new user());          userresultslist = userservice.finduser(user.getusername(), user.getfirstname(),                 user.getlastname());                      return new modelandview("userlist", "user", userresultslist);            }   } 

and jsp here

<body>     <form:form modelattribute="user" method="post" action="/finduser.html">         <table>             <tr>                 <td><form:label path="username">user id:</form:label></td>                 <td><form:input path="username" /></td>             </tr>             <tr>                 <td><form:label path="firstname">first name</form:label></td>                 <td><form:input path="firstname" /></td>             </tr>             <tr>                 <td><form:label path="lastname">last name:</form:label></td>                 <td><form:input path="lastname" /></td>             </tr>             <tr>                 <td colspan="2"><input type="submit" value="finduser" /></td>             </tr>         </table>     </form:form>             <table>             <tr>                 <td>user id</td>                 <td>first name</td>                 <td>last name</td>                 <td>email address</td>                 <td>last update date</td>                 <td>last update by</td>             </tr>         <c:foreach var="list" items="${userlist}">             <tr>                 <td>${list.userid}</td>                 <td>${list.username}</td>                 <td>${list.firstname}</td>                 <td>${list.lastname}</td>                 <td>${list.email}</td>                 <td>${list.lastupdatedby}</td>                 <td>${list.lastupdateddate}</td>                     <td><a href="listvendors.html?userid=${list.userid}">assignvendor</a></td>                       </tr>         </c:foreach>     </table> 

try add following line public modelandview getuserlist() method:

modelandview.addobject("user", new user()); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -