title: Thymeleaf th:href invoking both a post and get
body: <p>Following <a href="http://spring.io/guides/gs/validating-form-input/" rel="nofollow">this guide</a> I have configured a controller to handle the display and validation of a very simple form. I am using a Thymeleaf th:href to link to the form. </p>
  
  <pre><code>&lt;a th:href="@{/event/create}"&gt;Create Event&lt;/a&gt;
  </code></pre>
  
  <p>The problem is that both the showForm() and checkEventForm() are being invoked one after the other upon clicking the link. The result is a quick redirect away from the form back to / since checkEventForm() is also processed.</p>
  
  <p>Are both GET and POST meant to be processed?? </p>
  
  <p>The Link :</p>
  
  <pre><code>&lt;div id="sidebar"&gt;
      &lt;ol&gt;
        &lt;li&gt;&lt;a th:href="@{/}"&gt;Join Event&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a th:href="@{/event/create}"&gt;Create Event&lt;/a&gt;&lt;/li&gt;
      &lt;/ol&gt;   
  &lt;/div&gt;  
  </code></pre>
  
  <p>MvcConfig :</p>
  
  <pre><code>@Configuration
  public class MvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/home").setViewName("home");
          registry.addViewController("/").setViewName("home");
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry
              .addResourceHandler("/resources/**")
              .addResourceLocations("/resources/")
              .setCachePeriod(31556926);
      }
  
  }
  </code></pre>
  
  <p>CreateEventController :</p>
  
  <pre><code>@Controller
  public class CreateEventController {
  
      @RequestMapping(value="/event/create", method=RequestMethod.GET)
      public String showForm(CreateEvent event) {
          return "createEvent";
      }
  
      @RequestMapping(value="/event/create", method=RequestMethod.POST)
      public String checkEventForm(@Valid CreateEvent event, BindingResult bindingResult){
          if(bindingResult.hasErrors()){
              return "createEvent";
          }
          return "redirect:/";
      }
  
  }
  </code></pre>