title: Write handler methods for dynamically generated buttons and text boxes
body: <p>I have this small data on JSP form. I use JSTL to iterate over data. In each row, I have two dynamically generated textboxes and a button. Question is: how do I write a generic handler method for this data, which handles dynamically generated textboxes and buttons. Here is my JSP</p>
  
  <pre><code>&lt;c:forEach items="${menus}" var="menu" &gt; 
   &lt;tr&gt;
      &lt;td align="left" &gt;${menu.getMenuId()}&lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="text" name="menu_name" value="${menu.getMenuName()}"/&gt;&lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="text" name="menu_price" value="${menu.getMenuPrice()}"/&gt;&lt;/td&gt;
      &lt;td align="right"&gt;&lt;c:out value="${menu.getIsAvailable()}" /&gt;&lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="submit" value="Add Item ${menu.getMenuId()}"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/c:forEach&gt;
  
   &lt;h4&gt;Add Product&lt;/h4&gt;
   Name: &lt;input type="text" name="chosen_menu_name" /&gt;
   Price: &lt;input type="text" name="chosen_menu_price" /&gt;
   &lt;input type="submit" value="Add to cart"&gt;
  </code></pre>
  
  <p>And here is my controller (though I dont know what to put it there - at the moment I am using two seperate textbox and a button for taking the input)</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public ModelAndView AddMenu(@RequestParam("chosen_menu_name") String mymenu, @RequestParam("chosen_menu_price") String menu_price, @ModelAttribute("cart") ArrayList&lt;Menu&gt; mycart, Model model)
  {
      Menu menu = new Menu();
      menu.setMenuId(0);
      menu.setMenuName(mymenu);
      menu.setMenuPrice(Double.parseDouble(menu_price));
  
  
      model.addAttribute("menus", GetMenus());
      mycart.add(menu);
  
      return new ModelAndView("edit_menu");        
      //return "show_menu";
  }
  </code></pre>
  
  <p>As one can see from the JSP, I am using two seperate textboxes and a button for taking input and passing it to the controller. How do I write a generic handler method for this data, which handles dynamically generated textboxes and buttons?</p>