title: Request method 'GET' not supported in Spring Boot Controller
body: <p>I have the following code </p>
  
  <pre><code>@Controller
  @RequestMapping("/recipe")
  public class RecipeController {
  private IRecipeService recipeService;
  
  @Autowired
  public RecipeController(IRecipeService recipeService) {
      this.recipeService = recipeService;
  }
  
  @GetMapping("/{id}/show")
  public String showById(@PathVariable String id, Model model) {
  
      model.addAttribute("recipe", recipeService.findById(Long.valueOf(id)));
  
      return "recipe/show";
  }
  @GetMapping("/{id}/update")
      public String updateRecipe(@PathVariable String id, Model model) {
          model.addAttribute("recipe", recipeService.findCommandById(Long.valueOf(id)));
  
      return "recipe/recipeform";
  }
  
  @PostMapping("/")
  public String saveOrUpdate(@ModelAttribute RecipeCommand command) {
      RecipeCommand savedCommand = recipeService.saveRecipeCommand(command);
  
      return "redirect:/recipe/" + savedCommand.getId() + "/show";
  }}
  </code></pre>
  
  <p>Now when i go to <a href="http://localhost:8080/recipe/2/update" rel="nofollow noreferrer">http://localhost:8080/recipe/2/update</a> and click on <strong>Submit</strong> I call the <strong>@PostMapping</strong> method which upon updating redirects me to
  <code>return "redirect:/recipe/" + savedCommand.getId() + "/show";</code></p>
  
  <p>But then i get this error on the console </p>
  
  <pre><code>Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
  </code></pre>
  
  <p>and this on the web</p>
  
  <pre><code>There was an unexpected error (type=Method Not Allowed, status=405). Request method 'GET' not supported
  </code></pre>
  
  <p>When i change the @PostMapping to @RequestMapping or add additional @GetMaapping everything works</p>
  
  <p>Can any one explain this or what can i do so that @PostMapping works as expected.</p>
  
  <p>Possible Reason
  <a href="https://i.stack.imgur.com/YFvUe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YFvUe.png" alt="sample"></a></p>
  
  <p>UPDATE: as mentioned in the comments below - we can directly use @PathVariable in SpringData
  <a href="https://stackoverflow.com/a/39871080/4853910">https://stackoverflow.com/a/39871080/4853910</a></p>