title: Caused by: javax.validation.ConstraintViolationException: Validation failed for classes
body: <p><strong>First of all sorry for my language, english is not my mother language</strong></p>
  
  <p><em>Any help will be appreciated</em></p>
  
  <p>I'm trying to develop basic Spring Boot application with JPA.I have finished the most of the project, and project include form validation as well.Whenever I try to add new Person it's working well and I can get correct validate message from the valitador, also, I can update the person without any problem but whenever I make mistake the update form, the validator causes this error </p>
  
  <p>Error</p>
  
  <pre><code>Wed May 20 18:49:01 EET 2020
  There was an unexpected error (type=Internal Server Error, status=500).
  Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
  org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:543)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:744)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:712)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:631)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:385)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
      at sen3004.app6.service.App6Service$$EnhancerBySpringCGLIB$$88491962.update(&lt;generated&gt;)
      at sen3004.app6.web.App6Controller.update(App6Controller.java:78)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:108)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: javax.persistence.RollbackException: Error while committing the transaction
      at org.hibernate.internal.ExceptionConverterImpl.convertCommitException(ExceptionConverterImpl.java:81)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:104)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:534)
      ... 64 more
  Caused by: javax.validation.ConstraintViolationException: Validation failed for classes [sen3004.app6.model.Person] during update time for groups [javax.validation.groups.Default, ]
  List of constraint violations:[
      ConstraintViolationImpl{interpolatedMessage='boyut '3' ile '50' arasında olmalı', propertyPath=firstName, rootBeanClass=class sen3004.app6.model.Person, messageTemplate='{javax.validation.constraints.Size.message}'}
  ]
      at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:140)
      at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreUpdate(BeanValidationEventListener.java:88)
      at org.hibernate.action.internal.EntityUpdateAction.preUpdate(EntityUpdateAction.java:252)
      at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:122)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
      at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
      at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
      at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:108)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1344)
      at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:435)
      at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3221)
      at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2389)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
      ... 65 more
  </code></pre>
  
  <p>I looked at some solutions on the internet but it didn't work for me.Here the working valitador in add new person</p>
  
  <p><a href="https://i.stack.imgur.com/mWNOb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mWNOb.png" alt="Add New Person"></a></p>
  
  <p>I need the fix the problem and it should give me the same errors when I try to update the person (with mistakes)</p>
  
  <p>Here is my controller</p>
  
  <pre><code>package sen3004.app6.web;
  
  import javax.validation.Valid;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  import sen3004.app6.model.Person;
  import sen3004.app6.service.App6Service;
  
  @Controller
  public class App6Controller {
  
      @Autowired
      App6Service service;
  
      @RequestMapping(value = {"/", "index.html"}, method = RequestMethod.GET)
      public String getIndex() {
          return "index";
      }
  
  
      @RequestMapping(value = {"/display-form", "create.html"}, method = RequestMethod.GET)
      public ModelAndView displayForm() {
          ModelAndView mv = new ModelAndView("form");
          mv.addObject("person", new Person());
  
          return mv;
      }
  
      @RequestMapping(value = "/send", method = RequestMethod.POST)
      public ModelAndView processForm(@Valid @ModelAttribute Person person, BindingResult result) {
          ModelAndView mv = new ModelAndView();
          mv.addObject("person", person);
  
          if (result.hasErrors())
              mv.setViewName("form");
          else {
              mv.setViewName("result");
              service.create(person);
              mv.addObject("people", service.findAll());
          }
  
          return mv;
      }
  
      @RequestMapping(value = {"/list-people", "list.html"}, method = RequestMethod.GET)
      public ModelAndView list() {
          ModelAndView mv = new ModelAndView("result");
          mv.addObject("people", service.findAll());
  
          return mv;
      }
  
      @RequestMapping(value = {"/edit/{id}"}, method = RequestMethod.GET)
      public ModelAndView editList(@PathVariable long id) {
          ModelAndView mv = new ModelAndView("update");
          mv.addObject("person", service.findById(id));
          return mv;
      }
  
      @RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
      public ModelAndView update(@Valid @ModelAttribute Person person,
                                 BindingResult result,
                                 @PathVariable long id
                                 ) {
          ModelAndView mv = new ModelAndView();
          if (result.hasErrors()) {
              person.setId(id);
              mv.setViewName("update");
          }
          service.update(person);
          mv.addObject("people", service.findAll());
          mv.setViewName("result");
  
  
          return mv;
      }
  
      @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
      public ModelAndView delete(@PathVariable long id) {
          ModelAndView mv = new ModelAndView("result");
          service.delete(id);
          mv.addObject("people", service.findAll());
  
          return mv;
      }
  
  }
  </code></pre>
  
  <p>Here is my IPerson class and service Class</p>
  
  <pre><code>IPerson.java
  
  package sen3004.app6.service;
  
  import java.util.List;
  
  import sen3004.app6.model.Person;
  
  public interface IPerson {
      public List&lt;Person&gt; findAll();
  
      public Person findById(long id);
  
      public void create(Person person);
  
      public void delete(long id);
  
      public void update(Person person);
  
  }
  </code></pre>
  
  <p>App6Service.java</p>
  
  <pre><code>package sen3004.app6.service;
  
  import java.util.List;
  
  import javax.transaction.Transactional;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import sen3004.app6.dao.App6Repository;
  import sen3004.app6.model.Person;
  
  @Service
  @Transactional
  public class App6Service implements IPerson {
  
      @Autowired
      App6Repository repository;
  
      @Override
      public List&lt;Person&gt; findAll() {
          return repository.findAll();
      }
  
      @Override
      public Person findById(long id) {
          return repository.findById(id);
      }
  
      @Override
      public void create(Person person) {
          repository.create(person);
      }
  
      @Override
      public void delete(long id) {
          repository.delete(id);
      }
  
      @Override
      public void update(Person person) {
          repository.update(person);
      }
  
  }
  </code></pre>
  
  <p>App6Repository.java</p>
  
  <pre><code>package sen3004.app6.dao;
  
  import java.util.List;
  
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  
  import org.springframework.stereotype.Repository;
  
  import sen3004.app6.model.Person;
  import sen3004.app6.service.IPerson;
  
  @Repository
  public class App6Repository implements IPerson {
  
      @PersistenceContext
      private EntityManager entityManager;
  
      public List&lt;Person&gt; findAll(){
          return entityManager.createQuery("from Person", Person.class).getResultList();
      }
  
      public Person findById(long id){
          return entityManager.find(Person.class, id);
      }
  
      @Override
      public void update(Person person) {
          entityManager.merge(person);
  
      }
  
      @Override
      public void create(Person person) {
          entityManager.persist(person); 
      }
  
      @Override
      public void delete(long id) {
          entityManager.remove(entityManager.getReference(Person.class, id));
      } 
  }
  </code></pre>
  
  <p>Model
  Person.java</p>
  
  <pre><code>package sen3004.app6.model;
  
  import java.time.LocalDate;
  
  import javax.persistence.*;
  import javax.validation.constraints.*;
  
  import org.springframework.format.annotation.DateTimeFormat;
  
  @Entity
  @Table(name = "person")
  public class Person {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      @Size(min = 3, max = 50)
      @Column(name = "fname")
      private String firstName;
      @Size(min = 3, max = 50)
      @Column(name = "lname")
      private String lastName;
      @Past
      @DateTimeFormat(pattern = "dd-MM-yyyy")
      @Column(name = "dob")
      private LocalDate dateOfBirth;
      @Min(value = 12)
      @Column(name = "age")
      private int age;
      @Email
      @Column(name = "email")
      private String email;
      @Pattern(regexp = "[0-9\\s]{12}")
      @Column(name = "phone")
      private String phone;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public LocalDate getDateOfBirth() {
          return dateOfBirth;
      }
  
      public void setDateOfBirth(LocalDate dateOfBirth) {
          this.dateOfBirth = dateOfBirth;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getPhone() {
          return phone;
      }
  
      public void setPhone(String phone) {
          this.phone = phone;
      }
  }
  </code></pre>
  
  <p>app6application.java</p>
  
  <pre><code>package sen3004.app6;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class App6Application {
  
      public static void main(String[] args) {
          SpringApplication.run(App6Application.class, args);
      }
  }
  </code></pre>
  
  <p>messages.properties</p>
  
  <pre><code>Size.person.firstName=Value must contain at least 3, at most 50 characters.
  Size.person.lastName=Value must contain at least 3, at most 50 characters.
  Past.person.dateOfBirth=Value must be a past date.
  typeMismatch.person.dateOfBirth=Value must be a valid date (dd-mm-yyyy).
  Min.person.age=Our patients must have completed the age of 12 as per the age policy!
  Email.person.email=You must give valid Email!
  Pattern.person.phone=Phone number that given is invalid! For ex.: 9053839052094
  greeting=Hello! Welcome to Our Site!
  lang.change=Change The Language
  lang.eng=English
  lang.tr=Turkish
  msg.addperson =Add Person
  msg.firstname=First Name
  msg.lastname=Last Name
  msg.dateOfBirth=Date Of Birth
  msg.age=Age
  msg.email=Email
  msg.phone=Phone
  msg.persons=Persons
  msg.noperson=No Person Found!
  msg.id=ID
  msg.updateperson=Update Person
  </code></pre>
  
  <p>update.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ taglib prefix="s" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="x-ua-compatible" content="ie=edge"&gt;
      &lt;title&gt;&lt;s:message code="msg.updateperson"/&gt;&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
            integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"&gt;
      &lt;link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css"
            integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container my-5"&gt;
      &lt;h3&gt;&lt;s:message code="msg.updateperson"/&gt;&lt;/h3&gt;
      &lt;div class="card"&gt;
          &lt;div class="card-body"&gt;
              &lt;div class="col-md-8"&gt;
                  &lt;form:form method="post" action="/update/${person.id}" modelAttribute="person"&gt;
                      &lt;div class="row"&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="firstName" class="col-form-label"&gt;&lt;s:message code="msg.firstname"/&gt;&lt;/label&gt;
                              &lt;sf:input path="firstName" class="form-control" id="firstName"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="firstName"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="lastName" class="col-form-label"&gt;&lt;s:message code="msg.lastname"/&gt;&lt;/label&gt;
                              &lt;sf:input path="lastName" class="form-control" id="lastName"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="lastName"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="dateOfBirth" class="col-form-label"&gt;&lt;s:message code="msg.dateOfBirth"/&gt;&lt;/label&gt;
                              &lt;sf:input path="dateOfBirth" class="form-control" id="dateOfBirth"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="dateOfBirth"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="age" class="col-form-label"&gt;&lt;s:message code="msg.age"/&gt;&lt;/label&gt;
                              &lt;sf:input path="age" class="form-control" id="age"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="age"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="email" class="col-form-label"&gt;&lt;s:message code="msg.email"/&gt;&lt;/label&gt;
                              &lt;sf:input path="email" class="form-control" id="email"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="email"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="phone" class="col-form-label"&gt;&lt;s:message code="msg.phone"/&gt;&lt;/label&gt;
                              &lt;sf:input path="phone" class="form-control" id="phone"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="phone"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-8"&gt;
                              &lt;input type="submit" class="btn btn-primary" value="Submit"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form:form&gt;
                  &lt;p&gt;You can view a list of existing people &lt;a href="/list.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>form.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;%@ taglib prefix="s" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="x-ua-compatible" content="ie=edge"&gt;
      &lt;title&gt;&lt;s:message code="msg.addperson"/&gt;&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
            integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"&gt;
      &lt;link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css"
            integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container my-5"&gt;
      &lt;h3&gt;&lt;s:message code="msg.addperson"/&gt;&lt;/h3&gt;
      &lt;div class="card"&gt;
          &lt;div class="card-body"&gt;
              &lt;div class="col-md-8"&gt;
                  &lt;form:form method="post" action="/send" modelAttribute="person"&gt;
                      &lt;div class="row"&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="firstName" class="col-form-label"&gt;&lt;s:message code="msg.firstname"/&gt;&lt;/label&gt;
                              &lt;sf:input path="firstName" class="form-control" id="firstName"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="firstName"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="lastName" class="col-form-label"&gt;&lt;s:message code="msg.lastname"/&gt;&lt;/label&gt;
                              &lt;sf:input path="lastName" class="form-control" id="lastName"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="lastName"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="dateOfBirth" class="col-form-label"&gt;&lt;s:message code="msg.dateOfBirth"/&gt;&lt;/label&gt;
                              &lt;sf:input path="dateOfBirth" class="form-control" id="dateOfBirth"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="dateOfBirth"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="age" class="col-form-label"&gt;&lt;s:message code="msg.age"/&gt;&lt;/label&gt;
                              &lt;sf:input path="age" class="form-control" id="age"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="age"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="email" class="col-form-label"&gt;&lt;s:message code="msg.email"/&gt;&lt;/label&gt;
                              &lt;sf:input path="email" class="form-control" id="email"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="email"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-6"&gt;
                              &lt;label for="phone" class="col-form-label"&gt;&lt;s:message code="msg.phone"/&gt;&lt;/label&gt;
                              &lt;sf:input path="phone" class="form-control" id="phone"/&gt;
                              &lt;span class="text-danger"&gt;&lt;form:errors path="phone"/&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group col-md-8"&gt;
                              &lt;input type="submit" class="btn btn-primary" value="Submit"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form:form&gt;
                  &lt;p&gt;You can view a list of existing people &lt;a href="/list.html"&gt;here&lt;/a&gt;.&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>application.properties</p>
  
  <pre><code>management.endpoints.web.exposure.include=*
  
  info.app.name=App6
  info.app.desc=Spring Boot and JPA
  
  logging.level.org.springframework.web=DEBUG
  
  spring.mvc.view.prefix=/WEB-INF/jsp/
  spring.mvc.view.suffix=.jsp
  
  spring.datasource.schema=classpath:/sql/schema.sql
  spring.datasource.data=classpath:/sql/data.sql
  
  spring.jpa.hibernate.ddl-auto=none
  spring.jpa.properties.hibernate.show_sql=true
  #spring.jpa.properties.hibernate.format_sql=true
  </code></pre>