*Hello Friends.*
*Can anybody suggest me how to do serverside validation in spring while extemding controller with multiActionController*
*I am trying to do this with below code but its not working*
*public class LoginController extends MultiActionController {*
* *
* public LoginController()*
* {*
* setMethodNameResolver(new InternalPathMethodNameResolver());*
* setValidators(new Validator[] { new Validator() {*
* public boolean supports(Class clazz) {*
* return clazz.isAssignableFrom(LoginDetailDTO.class);*
* }*
* public void validate(Object command, Errors errors) {*
* ValidationUtils.rejectIfEmpty(errors, "userId", "", "Age is required");*
* ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "",*
* "Name is required");*
* }*
* *
* } });*
* }*
* HttpSession session;*
* *
* public ModelAndView login(HttpServletRequest request,*
* HttpServletResponse response)*
* throws Exception*
* {*
* *
* *
* return new ModelAndView("home");*
* }*
* *
* public ModelAndView validateUser(HttpServletRequest request,*
* HttpServletResponse response,LoginDetailDTO command)*
* throws Exception*
* {*
* *
* *
*
String fileName="";*
* String message="";*
* LoginDetailDTO d=(LoginDetailDTO)command;*
* *
* LoginDetailDTO loginDetailDTO=new LoginDetailDTO();*
* loginDetailDTO.setUserId(request.getParameter("userId"));*
* loginDetailDTO.setPassword(request.getParameter("password"));*
* *
* LoginDetailDTO user = getLoginServie().authenticateUser(loginDetailDTO);*
* *
* session=request.getSession();*
* ModelAndView mv=new ModelAndView();*
* mv.addObject("bindObj", request);*
* if(null != user)*
* {*
* session.setAttribute("user",user);*
* if(null != user.getFirstTimeLogin() && user.getFirstTimeLogin().equalsIgnoreCase("Y")){*
* *
* fileName = "password";*
* }else{*
* fileName="main";*
* }*
* }else{*
* //user name or password incorrect*
* fileName="home";*
* message="Incorrect User ID or Password";*
* }*
* *
* *
* return new ModelAndView(fileName,"message",message);*
* *
* }*
* *
* *
* *
* *
* *
* *
*}*
*Please help me on this*