diff --git a/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java
new file mode 100644
index 0000000000..586c2467fe
--- /dev/null
+++ b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java
@@ -0,0 +1,42 @@
+package com.baeldung.springmvcforms.controller;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.baeldung.springmvcforms.domain.Customer;
+import com.baeldung.springmvcforms.validator.CustomerValidator;
+
+@Controller
+public class CustomerController {
+
+ @Autowired
+ CustomerValidator validator;
+
+ @RequestMapping(value = "/customer", method = RequestMethod.GET)
+ public ModelAndView showForm() {
+ return new ModelAndView("customerHome", "customer", new Customer());
+ }
+
+ @PostMapping("/addCustomer")
+ public String submit(@Valid @ModelAttribute("customer") final Customer customer, final BindingResult result, final ModelMap model) {
+ validator.validate(customer, result);
+ if (result.hasErrors()) {
+ return "customerHome";
+ }
+ model.addAttribute("customerId", customer.getCustomerId());
+ model.addAttribute("customerName", customer.getCustomerName());
+ model.addAttribute("customerContact", customer.getCustomerContact());
+ model.addAttribute("customerEmail", customer.getCustomerEmail());
+ return "customerView";
+ }
+
+}
diff --git a/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/domain/Customer.java b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/domain/Customer.java
new file mode 100644
index 0000000000..8ecb2aa503
--- /dev/null
+++ b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/domain/Customer.java
@@ -0,0 +1,45 @@
+package com.baeldung.springmvcforms.domain;
+
+public class Customer {
+ private String customerId;
+ private String customerName;
+ private String customerContact;
+ private String customerEmail;
+
+ public Customer() {
+ super();
+ }
+
+ public String getCustomerId() {
+ return customerId;
+ }
+
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ public String getCustomerContact() {
+ return customerContact;
+ }
+
+ public void setCustomerContact(String customerContact) {
+ this.customerContact = customerContact;
+ }
+
+ public String getCustomerEmail() {
+ return customerEmail;
+ }
+
+ public void setCustomerEmail(String customerEmail) {
+ this.customerEmail = customerEmail;
+ }
+
+}
diff --git a/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java
new file mode 100644
index 0000000000..94a7bd0ebd
--- /dev/null
+++ b/spring-mvc-forms/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java
@@ -0,0 +1,28 @@
+package com.baeldung.springmvcforms.validator;
+
+import org.springframework.stereotype.Component;
+import org.springframework.validation.Errors;
+import org.springframework.validation.ValidationUtils;
+import org.springframework.validation.Validator;
+
+import com.baeldung.springmvcforms.domain.Customer;
+
+@Component
+public class CustomerValidator implements Validator {
+
+ @Override
+ public boolean supports(Class> clazz) {
+ return Customer.class.isAssignableFrom(clazz);
+ }
+
+ @Override
+ public void validate(Object target, Errors errors) {
+
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "customerId", "error.customerId", "Customer Id is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "customerName", "error.customerName", "Customer Name is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "customerContact", "error.customerNumber", "Customer Contact is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "customerEmail", "error.customerEmail", "Customer Email is required.");
+
+ }
+
+}
diff --git a/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerHome.jsp b/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerHome.jsp
new file mode 100644
index 0000000000..df34a47cc0
--- /dev/null
+++ b/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerHome.jsp
@@ -0,0 +1,47 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+
+
+
+Form Example - Add Customer
+
+
+
+ Welcome, Enter The Customer Details
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerView.jsp b/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerView.jsp
new file mode 100644
index 0000000000..ab2631bd02
--- /dev/null
+++ b/spring-mvc-forms/src/main/webapp/WEB-INF/views/customerView.jsp
@@ -0,0 +1,28 @@
+<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
+
+
+Spring MVC Form Handling
+
+
+
+ Submitted Customer Information
+
+
+ | Customer Id : |
+ ${customerId} |
+
+
+ | Customer Name : |
+ ${customerName} |
+
+
+ | Customer Contact : |
+ ${customerContact} |
+
+
+ | Customer Email : |
+ ${customerEmail} |
+
+
+
+
\ No newline at end of file