title: Link a method from a controller to a button click in Spring boot Java
body: <p>I am working on a spring java project. I have a view that contains multiple buttons. Each one will fire a method from the controller. So how can I link my button click function to a specific method in my controller?</p>
  
  <p>Here is some of the HTML from the MainView.html</p>
  
  <pre><code> &lt;button class="btn btn-success btn-default"&gt;
   &lt;span class="glyphicon glyphicon-play-circle" aria-hidden="true"&gt;&lt;/span&gt;
   &lt;/button&gt;
  </code></pre>
  
  <p>Here is the MainController class:</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  
  
  @Controller
  public class MainController
  {
  
      @GetMapping(value="/")
      public String home() 
      {
           return "views/MainView";
      }
  
       public void run() //I want to link the button click to this method
       {  
           System.out.println("Test1");
           System.out.println("Test2");
           System.out.println("Test3");
           System.out.println("Test4");
       }
  }
  </code></pre>