SimpleFormController and Velocity error
I've been getting the following error, no matter what I've tried.
Code:
Could not find Errors instance for bean [command] in request:
I've got this in my controller:
Code:
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors ) throws Exception {
User user = (User) command;
ModelAndView view;
boolean isValidUser = authHandler.isValidUser(user);
if(!isValidUser) {
errors.reject("invalidLogin", null, "Invalid username and password conbination");
view = showForm(request, response, errors);
} else {
HttpSession session = request.getSession();
session.setAttribute("user", user);
view = new ModelAndView(getSuccessView(), errors.getModel());
}
return view;
}
And I've got this in my login.vm file
Code:
<html>
<H2>Login</H2>
<form method="post" action="editUser.html">
#springBind("command")
<table>
</html>
What am I missing?
Re: SimpleFormController and Velocity error
Quote:
Originally Posted by davidmitchell
And I've got this in my login.vm file
Code:
<html>
<H2>Login</H2>
<form method="post" action="editUser.html">
#springBind("command")
<table>
</html>
What am I missing?
err, half of your Velocity template from the look of it :)
Is your command object actually called "command" or did you set it to something else via the bean property "commandName" on your form controller definition in *-servlet.xml?
Regards,