I need you help me for this error in my code
form
<form:form action="user.do" method="POST" commandName="user">
<div class="form-group">
<form:input path="userName" cssClass="form-control "/>
</div>
<div class="form-group">
<form:password path="password" cssClass="form-control "/>
</div>
<div class="form-group">
<input type="submit" name="action" value="Login" class="btn btn-info col-xs-12"/>
</div>
</form:form>
Controller
@RequestMapping(value="/user.do", method=RequestMethod.POST)
public String doAction(@ModelAttribute Users user,Model model, BindingResult result,Map<String, Object> map)
{
Users user1 = new Users();
user1 = userService.userLogin(user);
user1 = userService!=null ? user1 : new Users();
map.put("user", userService.userLogin(user));
return "home";
}
Implementation Dao Clsss
package com.hmy.Dao.Impl;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.hmy.Dao.UsersDao;
import com.hmy.Model.Users;
@Repository
public class UsersDaoImpl implements UsersDao {
@Autowired
private SessionFactory session;
@Override
public Users userLogin(Users user) {
return (Users)session.getCurrentSession().get(Users.class, user.getUserName());
}
}
[Implementation of Service class][1]
Error display when try to submit data
HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.hmy.Controller.UsersController.doAction(com.hmy.Model.Users,org.springframework.ui.Model,org.springframework.validation.BindingResult,java.util.Map)]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
type Exception report
message Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.hmy.Controller.UsersController.doAction(com.hmy.Model.Users,org.springframework.ui.Model,org.springframework.validation.BindingResult,java.util.Map)]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.hmy.Controller.UsersController.doAction(com.hmy.Model.Users,org.springframework.ui.Model,org.springframework.validation.BindingResult,java.util.Map)]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause
org.springframework.web.bind.annotation.support.HandlerMethodInvocationException: Failed to invoke handler method [public java.lang.String com.hmy.Controller.UsersController.doAction(com.hmy.Model.Users,org.springframework.ui.Model,org.springframework.validation.BindingResult,java.util.Map)]; nested exception is java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:181) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause
java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature! org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:327) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/8.0.28 logs.
So i need your help to solve this, Because it my fisrt time to try Spring with hibernate