title: Very simple spring MVC button click
body: <p>I have the following code in my SampleController;</p>
  
  <pre><code>@Controller
  public class SampleController {
  
      @RequestMapping("home")
      public String loadHomePage(Model m) {
          m.addAttribute("name", "CodeTutr");
          return "home";
      }
  
      @RequestMapping(value="/test", method=RequestMethod.GET)
      public String handlePost(@RequestParam String action, Model m) {
          if( action.equals("save") ){
              //handle save
           }
           else if( action.equals("renew") ){
              //handle renew
           }
          m.addAttribute("name", "change");
          return "home";
      }
  }
  </code></pre>
  
  <p>on page load the attribute I set it successful shown on the web page. I am trying to get my head around button clicks on spring mvc below is my jsp code;</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Sample Application&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Hello, ${name}!&lt;/h1&gt;
      &lt;input type="submit" name="action" value="save" /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My input does not do anything, the method handlePost is never hit. I was trying to change the attribute "name" to the word "change", I am not sure what I am doing incorrectly.</p>