Package com.controllers

Source Code of com.controllers.ValidationController

package com.controllers;

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;

@Controller
@RequestMapping("/validationform.html")
public class ValidationController {

  // Display the form on the get request
  @RequestMapping(method = RequestMethod.GET)
  public String showValidatinForm(Map model) {
    ValidationForm validationForm = new ValidationForm();
    model.put("validationForm", validationForm);
    return "validationform";
  }

  // Process the form.
  @RequestMapping(method = RequestMethod.POST)
  public String processValidatinForm(@Valid ValidationForm validationForm,
      BindingResult result, Map model) {
    if (result.hasErrors()) {
     
      return "validationform";
    }
    // Add the saved validationForm to the model
    model.put("validationForm", validationForm);
    return "validationsuccess";
  }
 
 

}
TOP

Related Classes of com.controllers.ValidationController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.