Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.kalai.controller; import com.kalai.hibernatevalidator; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.*; import org.springframework.web.bind.annotation.*; /** * * @author kalaiselvan.a */ @Controller public class HibernateValidatorController { @RequestMapping("/springvalidation") public String hibernate_valdiate(HttpSession session, ModelMap map) { String username = ""; try { username = (String) session.getAttribute("username"); if (!username.equals("") && username.trim().length() != 0) { map.addAttribute("status", "entry"); return "hibernatevalidate"; } else { return "index"; } } catch (Exception e) { return "PageNotFound"; } } @RequestMapping(value = "/springvalidationstore", method = RequestMethod.POST) public String springvalidationstore(HttpSession session, ModelMap map, @ModelAttribute("hibernatevalidate") hibernatevalidator hibval, BindingResult result) { String username = ""; try { username = (String) session.getAttribute("username"); if (!username.equals("") && username.trim().length() != 0) { map.addAttribute("status", "Stroe"); map.addAttribute("hibval", new hibernatevalidator()); return "hibernatevalidate"; } else { return "index"; } } catch (Exception e) { return "PageNotFound"; } } }