title: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
body: <p>I am studying spring boot and spring jpa .
  I was able to successfully read and write into the database, but the problem occurs while updating the data.</p>
  
  <pre><code>There was an unexpected error (type=Method Not Allowed, status=405).
  Request method 'GET' not supported
  org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
  </code></pre>
  
  <p>I am trying to update data of table : Person ( Id, Name , Age) using a html form. It accepts the data, and using spring jpa  I am trying to update it in MySQL database.</p>
  
  <p>I am getting the following at console when trying to update the data, after submitting the form</p>
  
  <pre><code>&gt; WARN 5176 --- [nio-8080-exec-1]
  &gt; .w.s.m.s.DefaultHandlerExceptionResolver : Resolved
  &gt; [org.springframework.web.HttpRequestMethodNotSupportedException:
  &gt; Request method 'GET' not supported]
  </code></pre>
  
  <p>My code is here : 
  updateperson form : </p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
      &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Title&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;h1&gt;Enter new details&lt;/h1&gt;
      &lt;form action="updatePerson" method="post"&gt;
          Id   : &lt;input type="number" name="id"&gt;&lt;br&gt;
          Name :&lt;input type = "text" name = "name"&gt;&lt;br&gt;
          Age : &lt;input type = "number" name = "age"&gt;&lt;br&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>PersonRepository.java</p>
  
  <pre><code>package com.example.demo.repository;
  
  import com.example.demo.model.Person;
  import org.springframework.data.jpa.repository.Query;
  import org.springframework.data.repository.CrudRepository;
  import org.springframework.stereotype.Repository;
  
  import java.util.List;
  
  @Repository
  public interface PersonRepository extends CrudRepository&lt;Person , Integer&gt; {
      List&lt;Person&gt; findByName(String name);
      List&lt;Person&gt; findByAge(int age);
      List&lt;Person&gt; findAll();
  }
  </code></pre>
  
  <p>PersonController.java</p>
  
  <pre><code>    package com.example.demo.controller;
  
  import com.example.demo.model.Person;
  import com.example.demo.repository.PersonRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @Controller
  public class PersonController {
      @Autowired
      PersonRepository personRepository;
  
  
      @GetMapping("update")
      public String updatePerson(){
          System.out.println("update to updateperson html");
          return "updateperson";
      }
      @PutMapping("/updatePerson")
      public String updatePerson(Person person){
          System.out.println("UPDATING TO" + person.getAge()+" : "+person.getName() + " : "+person.getPid());
          personRepository.save(person);
          return "updateperson";
      }  
  
  }
  </code></pre>
  
  <p>Person.java  </p>
  
  <pre><code>package com.example.demo.model;
  
  import org.springframework.stereotype.Component;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  
  
  @Entity
  public class Person {
      @Id
      @GeneratedValue
      int pid;
  
      String name;
      int age;
  
       public Person() {
      }
  
      public Person(int pid, String name, int age) {
          this.pid = pid;
          this.name = name;
          this.age = age;
      }
  
  //getter and setters
  }
  </code></pre>
  
  <p>The URL to which I'm sending the request:</p>
  
  <pre><code>localhost:8080/updatePerson?id=4&amp;name=personame&amp;age=34
  </code></pre>