title: Input validation doesn't work in Spring + Thymeleaf
body: <p>I am new to spring and I explore it using &quot;Spring in action 5&quot; book. I do similar actions with my website, I have written 2 controllers and 2 html files for pages. The first page is a form for pizza creation. the second is order submission. My code for controllers is practically the same as in the book.  Everything worked fine until I started to validate form inputs. I did everything that needed in Pizza, Order classes and controllers.</p>
  <p>Order class:</p>
  <pre><code>@Data
  public class Order {
      @NotBlank(message = &quot;Name is required&quot;)
      private String name;
  
      @NotBlank(message = &quot;Street os required&quot;)
      private String street;
  
      @NotBlank(message = &quot;City is required&quot;)
      private String city;
  
      @NotBlank(message = &quot;State is required&quot;)
      private String state;
  
      @NotBlank(message = &quot;Zip is required&quot;)
      private String zip;
  
      @CreditCardNumber(message = &quot;Not a valid credit card number&quot;)
      private String ccNumber;
  
      @Pattern(regexp = &quot;^(0[1-9]|1[0-2])([\\/])([1-9][0-9])$&quot;)
      private String ccExpiration;
  
      @Digits(integer = 3, fraction = 0, message = &quot;Invalid CVV&quot;)
      private String ccCVV;
  }
  </code></pre>
  <p>Pizza class:</p>
  <pre><code>@Data
  public class Pizza {
      @NotNull
      @Size(min = 3, message = &quot;Name must be at least 3 characters long&quot;)
      private String name;
  
      @Size(min = 1, message = &quot;You must choose at least 1 ingredient&quot;)
      private List&lt;String&gt; ingredients;
  }
  </code></pre>
  <p>Controller for pizza creation:</p>
  <pre><code>@Slf4j
  @Controller
  @RequestMapping(&quot;/create&quot;)
  public class CreatePizzaController {
      @GetMapping
      public String showCreationForm(Model model){
          List&lt;Ingredient&gt; ingredients = Arrays.asList(
                  new Ingredient(&quot;CLS22&quot;, &quot;Classic base 22cm&quot;, Ingredient.Type.BASIC),
                  new Ingredient(&quot;CLS30&quot;, &quot;Classic base 30cm&quot;, Ingredient.Type.BASIC),
                  new Ingredient(&quot;PEPE&quot;, &quot;Pepperoni&quot;, Ingredient.Type.MEAT),
                  new Ingredient(&quot;HAM&quot;, &quot;Ham&quot;, Ingredient.Type.MEAT),
                  new Ingredient(&quot;CHMPG&quot;, &quot;Champignons&quot;, Ingredient.Type.VEGGIES),
                  new Ingredient(&quot;CUCU&quot;, &quot;Cucumbers&quot;, Ingredient.Type.VEGGIES),
                  new Ingredient(&quot;PARM&quot;, &quot;Parmesan cheese&quot;, Ingredient.Type.CHEESE),
                  new Ingredient(&quot;MOZ&quot;, &quot;Mozzarella cheese&quot;, Ingredient.Type.CHEESE),
                  new Ingredient(&quot;BARBS&quot;, &quot;Barbecue sauce&quot;, Ingredient.Type.SAUCE),
                  new Ingredient(&quot;TOMAS&quot;, &quot;Tomato sauce&quot;, Ingredient.Type.SAUCE)
                  );
  
          Ingredient.Type[] types = Ingredient.Type.values();
          for(Ingredient.Type type: types){
              model.addAttribute(type.toString().toLowerCase(), filterByType(ingredients, type));
          }
          model.addAttribute(&quot;create&quot;, new Pizza());
          return &quot;create&quot;;
      }
  
      @PostMapping
      public String processCreation(@Valid Pizza pizza, Errors errors){
          if(errors.hasErrors()){
              return &quot;create&quot;;
          }
          //Save creation...
          log.info(&quot;Processing creation: &quot; + pizza);
          return &quot;redirect:/orders/current&quot;;
      }
  
      private List&lt;Ingredient&gt; filterByType(List&lt;Ingredient&gt; ingredients, Ingredient.Type type) {
          List&lt;Ingredient&gt; filtered = new ArrayList&lt;&gt;();
          for (Ingredient ingredient:ingredients){
              if(ingredient.getType() == type){
                  filtered.add(ingredient);
              }
          }
          return filtered;
      }
  }
  </code></pre>
  <p>Controller for the form submission:</p>
  <pre><code>@Slf4j
  @Controller
  @RequestMapping(&quot;/orders&quot;)
  public class OrderController {
      @GetMapping(&quot;/current&quot;)
      public String orderForm(Model model){
          model.addAttribute(&quot;order&quot;, new Order());
          return &quot;orderForm&quot;;
      }
      @PostMapping
      public String processOrder(@Valid Order order, Errors errors) {
          if (errors.hasErrors()){
              return &quot;orderForm&quot;;
          }
          log.info(&quot;Order submitted: &quot; + order);
          return &quot;redirect:/&quot;;
      }
  }
  </code></pre>
  <p>The problem is in validating pizza creation. When I enter invalid name of the pizza and click button to submit my pizza I get Whitelabel Error Page.</p>
  <pre><code>2021-03-11 21:48:56.740 ERROR 124 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: &quot;class path resource [templates/create.html]&quot;)] with root cause
  
  java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'create' available as request attribute
      at org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:153) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.support.RequestContext.getBindStatus(RequestContext.java:903) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.thymeleaf.spring5.context.webmvc.SpringWebMvcThymeleafRequestContext.getBindStatus(SpringWebMvcThymeleafRequestContext.java:227) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:306) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.util.FieldUtils.getBindStatus(FieldUtils.java:253) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.util.FieldUtils.getBindStatus(FieldUtils.java:227) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.processor.AbstractSpringFieldTagProcessor.doProcess(AbstractSpringFieldTagProcessor.java:174) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.engine.ProcessorTemplateHandler.handleStandaloneElement(ProcessorTemplateHandler.java:918) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleStandaloneElementEnd(TemplateHandlerAdapterMarkupHandler.java:260) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleStandaloneElementEnd(InlinedOutputExpressionMarkupHandler.java:256) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleStandaloneElementEnd(OutputExpressionInlinePreProcessorHandler.java:169) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleStandaloneElementEnd(InlinedOutputExpressionMarkupHandler.java:104) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.attoparser.HtmlElement.handleStandaloneElementEnd(HtmlElement.java:79) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.HtmlMarkupHandler.handleStandaloneElementEnd(HtmlMarkupHandler.java:241) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.MarkupEventProcessorHandler.handleStandaloneElementEnd(MarkupEventProcessorHandler.java:327) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.ParsingElementMarkupUtil.parseStandaloneElement(ParsingElementMarkupUtil.java:96) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:706) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.attoparser.MarkupParser.parse(MarkupParser.java:257) ~[attoparser-2.0.5.RELEASE.jar:2.0.5.RELEASE]
      at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:666) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring5-3.0.12.RELEASE.jar:3.0.12.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1393) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1138) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1077) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) ~[tomcat-embed-core-9.0.43.jar:4.0.FR]
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.4.jar:5.3.4]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.43.jar:4.0.FR]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.4.5.jar:5.4.5]
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.3.4.jar:5.3.4]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.4.jar:5.3.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.4.jar:5.3.4]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.43.jar:9.0.43]
      at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
  </code></pre>
  <p>It seems like I am not working properly with attributes in my <em>CreatePizzaController</em> class, it must be broken, though I'll give html code below. I tried to replace <em>Errors</em> parameter in <em>processCreation</em> method to <em>BindingResult</em> parameter and check for erros but it works the same. Please help me, I don't really understand why my code doesn't work with input validation.</p>
  <p>orderForm.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method=&quot;POST&quot; th:action=&quot;@{/orders}&quot; th:object=&quot;${order}&quot;&gt;
      &lt;h1&gt;Order your pizza creations!&lt;/h1&gt;
      &lt;img th:src=&quot;@{/images/pizza_logo.jpg}&quot;/&gt;
      &lt;a th:href=&quot;@{/create}&quot; id=&quot;another&quot;&gt;Create another pizza&lt;/a&gt;&lt;br/&gt;
      &lt;div th:if=&quot;${#fields.hasErrors()}&quot;&gt;
          &lt;span class=&quot;validationError&quot;&gt;Please correct the problems below and resubmit.&lt;/span&gt;
      &lt;/div&gt;
      &lt;h3&gt;Deliver my pizza masterpiece to...&lt;/h3&gt;
      &lt;label for=&quot;name&quot;&gt;Name: &lt;/label&gt;
          &lt;input type=&quot;text&quot; th:field=&quot;*{name}&quot;/&gt;
      &lt;br/&gt;
      &lt;label for=&quot;street&quot;&gt;Street address: &lt;/label&gt;
       &lt;input type=&quot;text&quot; th:field=&quot;*{street}&quot;/&gt;
      &lt;br/&gt;
      &lt;label for=&quot;city&quot;&gt;City: &lt;/label&gt;
       &lt;input type=&quot;text&quot; th:field=&quot;*{city}&quot;/&gt;
      &lt;br/&gt;
      &lt;label for=&quot;state&quot;&gt;State: &lt;/label&gt;
       &lt;input type=&quot;text&quot; th:field=&quot;*{state}&quot;/&gt;
      &lt;br/&gt;
      &lt;label for=&quot;zip&quot;&gt;Zip code: &lt;/label&gt;
       &lt;input type=&quot;text&quot; th:field=&quot;*{zip}&quot;/&gt;
      &lt;br/&gt;
  
      &lt;h3&gt;Here's how I'll pay...&lt;/h3&gt;
      &lt;label for=&quot;ccNumber&quot;&gt;Credit Card #: &lt;/label&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{ccNumber}&quot;/&gt;
      &lt;span class=&quot;validationError&quot;
            th:if=&quot;${#fields.hasErrors('ccNumber')}&quot;
            th:errors=&quot;*{ccNumber}&quot;&gt;CC Num Error&lt;/span&gt;
      &lt;br/&gt;
  
      &lt;label for=&quot;ccExpiration&quot;&gt;Expiration: &lt;/label&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{ccExpiration}&quot;/&gt;
      &lt;span class=&quot;validationError&quot;
            th:if=&quot;${#fields.hasErrors('ccExpiration')}&quot;
            th:errors=&quot;*{ccExpiration}&quot;&gt;CC Num Error&lt;/span&gt;
      &lt;br/&gt;
  
      &lt;label for=&quot;ccCVV&quot;&gt;CVV: &lt;/label&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{ccCVV}&quot;/&gt;
      &lt;br/&gt;
      &lt;input type=&quot;submit&quot; value=&quot;Submit order&quot;/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>create.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Title&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; th:href=&quot;@{/styles/style.css}&quot; /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h3&gt;Create your pizza:&lt;/h3&gt;
  &lt;img th:src=&quot;@{/images/pizza_logo.jpg}&quot; width=&quot;200&quot; height=&quot;200&quot;/&gt;
  
  &lt;form method=&quot;post&quot; th:object=&quot;${create}&quot;&gt;
      &lt;div class=&quot;grid&quot;&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;basics&quot;&gt;
              &lt;h3&gt;Choose the basic: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${basic}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;radio&quot; checked th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;meat&quot;&gt;
              &lt;h3&gt;Choose meat: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${meat}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;veggies&quot;&gt;
              &lt;h3&gt;Choose vegetables: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${veggies}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;sauce&quot;&gt;
              &lt;h3&gt;Choose sauce: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${sauce}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;cheese&quot;&gt;
              &lt;h3&gt;Choose cheese: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${cheese}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;submit-button&quot;&gt;
          &lt;h3&gt;Name your pizza:&lt;/h3&gt;
          &lt;input class=&quot;submit-field&quot; type=&quot;text&quot; th:field=&quot;*{name}&quot;/&gt;
          &lt;br/&gt;
          &lt;button&gt;Submit your pizza&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>P.S
  Adding @ModelAttribute annotation worked, my problem is solved. But now I get another problem related to thymeleaf. When I add thymeleaf code to handle input error and I try to enter invalid name of pizza, thymeleaf just doesn't generate my checkboxes. Here is create.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;title&gt;Title&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; th:href=&quot;@{/styles/style.css}&quot; /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h3&gt;Create your pizza:&lt;/h3&gt;
  &lt;img th:src=&quot;@{/images/pizza_logo.jpg}&quot; width=&quot;200&quot; height=&quot;200&quot;/&gt;
  
  &lt;form method=&quot;post&quot; th:object=&quot;${create}&quot;&gt;
      &lt;div class=&quot;grid&quot;&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;basics&quot;&gt;
              &lt;h3&gt;Choose the basic: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${basic}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;radio&quot; checked th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;meat&quot;&gt;
              &lt;h3&gt;Choose meat: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${meat}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;veggies&quot;&gt;
              &lt;h3&gt;Choose vegetables: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${veggies}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;sauce&quot;&gt;
              &lt;h3&gt;Choose sauce: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${sauce}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;ingredient-group&quot; id=&quot;cheese&quot;&gt;
              &lt;h3&gt;Choose cheese: &lt;/h3&gt;
              &lt;div th:each=&quot;ingredient : ${cheese}&quot;&gt;
                  &lt;input name=&quot;ingredients&quot; type=&quot;checkbox&quot; th:value=&quot;${ingredient.id}&quot;/&gt;
                  &lt;span class=&quot;checktext&quot; th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class=&quot;submit-button&quot;&gt;
          &lt;h3&gt;Name your pizza:&lt;/h3&gt;
          &lt;input class=&quot;submit-field&quot; type=&quot;text&quot; th:field=&quot;*{name}&quot;/&gt;
          &lt;span class=&quot;validationError&quot;
                th:if=&quot;${#fields.hasErrors('name')}&quot;
                th:errors=&quot;*{name}&quot;&gt;Error&lt;/span&gt;
          &lt;br/&gt;
          &lt;button&gt;Submit your pizza&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Everything is fine until I click submit button with invalid name field. After that my error message appears, there are no exceptions as well as my checkboxes.
  <a href="https://i.stack.imgur.com/FmxGX.png" rel="nofollow noreferrer">this is how it looks like</a><br />
  <a href="https://i.stack.imgur.com/npKUD.png" rel="nofollow noreferrer">and this is generated html code</a></p>