package com.controllers;
import java.util.*;
import com.form.EmpLginDetform;
import com.form.ValidationForm;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.form.EmpLginDetform;
@Controller
@RequestMapping("/EmpLginDetform.html")
public class EmpController {
@RequestMapping(method = RequestMethod.GET)
public String emplogingpage(Map model)
{
EmpLginDetform EmpLginDetform=new EmpLginDetform();
model.put("EmpLginDetform", EmpLginDetform);
return "EmpLogin";
}
@RequestMapping(method=RequestMethod.POST )
public String emploginsubmit(@Valid EmpLginDetform EmpLginDetform,BindingResult errorresults,Map model)
{
if(errorresults.hasErrors())
{
List errors=errorresults.getAllErrors();
Iterator ite=errors.iterator();
while(ite.hasNext())
{
System.out.println("erros is:-"+ite.next());
}
System.out.println("in errors"+errorresults.getErrorCount());
model.put("EmpLginDetform", EmpLginDetform);
return "EmpLogin";
}
else
{
model.put("EmpLginDetform", EmpLginDetform);
return "dummyPage";
}
}
}