title: how to resolve Request method 'GET' not supported
body: <p>I am getting below  warning as </p>
  
  <p><code>WARN  [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-1) Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]</code></p>
  
  <p>I have already set the method as <code>POST</code> but still I'm getting the above error. I'm getting this warning message for my delete controller all other CRUD operations are working fine, except delete.</p>
  
  <p>Please find below code 
  Controller mapped deleteproducts :</p>
  
  <pre><code>@RequestMapping(value="/deleteproducts", method= RequestMethod.POST)
      public String deleteProduct(@PathVariable("productId")int productId) {
          IProductsDAO ip = new ProductsDAOImpl();
          boolean b = ip.deleteProduct(productId);
          if(b)
              return "success";
          else
              return "deleteproducts";
  </code></pre>
  
  <p>here's my jsp view:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="update product form" action="${pageContext.request.contextPath}/deleteproducts" method="post" role="form" style="display: none;"&gt;
      &lt;div class="form-group row"&gt;
          &lt;label for="product Id" class="col-sm-2 col-form-label"&gt;Id&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              &lt;input type="text" name="productId" class="form-control" id="productid" placeholder="Enter the product Id you want to delete"&gt;
          &lt;/div&gt;
      &lt;/div&gt;  
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>DAOimplementation for delete Method call:</p>
  
  <pre><code>public boolean deleteProduct(int productId)
      {
          boolean b = true;
          try
          {
              sess.beginTransaction();
              Products p = (Products)sess.load(Products.class, new Integer(productId));
              sess.delete(p);
              sess.getTransaction().commit();
          }catch(Exception ex)
          {
              sess.getTransaction().rollback();
              b = false;
          }
          return b;
      }
  </code></pre>
  
  <p>can some one now tell me what changes should I make in my code to fix this ?</p>
  
  <p>Thank you!</p>
  
  <p>edit 1:</p>
  
  <pre><code>@DeleteMapping(value="/deleteproducts/{productId}")
      public String deleteProduct(@PathVariable("productId")int productId) {
          IProductsDAO ip = new ProductsDAOImpl();
          boolean b = ip.deleteProduct(productId);
          if(b)
              return "success";
          else
              return "deleteproducts";
      }
  </code></pre>
  
  <p>still getting a warning as:</p>
  
  <pre><code>WARN  [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-1) Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
  </code></pre>