title: Spring MVC, two buttons work with one form, how they work together?
body: <p><img src="https://i.stack.imgur.com/esgep.png" alt="enter image description here"></p>
  
  <p>What I am doing here is when I enter a bookname in textbook and click edit button. The textboxes below will show this book's all information. Then I can edit information in the same textboxes. In the end, I click update and the new information will be updated.I have edit part done, I can edit all information by given certain bookname. Now I am confused how to do update part, because both edit and update will use the same form(those textboxes), then how to handle post or get request? Someone can explain to me? Thank you.</p>
  
  <p>controller:</p>
  
  <pre><code>@RequestMapping(value = "/edit", method=RequestMethod.GET)
  public String getEditBookForm(@ModelAttribute("editBook") Book editBook, HttpServletRequest request) {
  
          return "editbook";
      }
  
  @RequestMapping(value = "/edit", method = RequestMethod.POST)
  public ModelAndView processEditBookForm(@ModelAttribute("editBook") Book editBook ){
  
      ModelAndView mv = new ModelAndView("editbook");
      mv.addObject("resulteditBook",bookService.getBookByName(editBook.getBookName()) );
      return mv;
  }
  </code></pre>
  
  <p>jsp:</p>
  
  <pre><code>&lt;form:form modelAttribute="editBook" &gt;
  
          &lt;div&gt;Enter BOOK NAME: &lt;input type="text" name=bookName
                  style="width: 100"&gt;
  
              &lt;input type="submit" value="Edit" name="edit"&gt;
      &lt;/div&gt;
      &lt;/form:form&gt;
  
  &lt;form:form modelAttribute="updateBook" &gt;
      ......
      &lt;p&gt;
          &lt;input type="submit" value="Update" name="update"&gt;
      &lt;/p&gt;
      &lt;/form:form&gt;
  </code></pre>