i am new in spring. and i am developing login application in spring mvc . while setting the values in LoginForm its is showing "null". please help me. want to get out of it!! Any help will be appriciated.
My controller is:
@Controller
@RequestMapping("loginform.html")
public class LoginController extends MainController {
private String password;
private LoginDAO loginDAO;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@RequestMapping(method = RequestMethod.GET)
public String showForm(Map model) {
LoginForm loginForm = new LoginForm();
model.put("loginForm", loginForm);
return "loginform";
}
@RequestMapping(method = RequestMethod.POST)
public String processForm(@Valid LoginForm loginForm, BindingResult result,
Map model) {
//String userName = "Admin";
//String password = "root";
if (result.hasErrors()) {
return "loginform";
}
try {
loginForm.setUserName(userName);
loginForm.setPassword(password);
loginDAO = new LoginDAOImpl();
LoginForm tempLoginForm = loginDAO.validateUser(loginForm);
if (tempLoginForm == null) {
return "loginsuccess";
}
} catch (Exception e) {
}
model.put("loginForm", loginForm);
return "loginerror";
}
}