RequestMethod POST and GET in the same Controller? RequestMethod POST and GET in the same Controller? spring spring

RequestMethod POST and GET in the same Controller?


Make it an array of method values that it gets mapped to, like so:

@RequestMapping(value = "/esta", method = {RequestMethod.POST, RequestMethod.GET})


Or you can write separate methods

@RequestMapping(value = {#some_vale}, method = RequestMethod.GET)public random_method #1{}@RequestMapping(value = { #some_value }, method = RequestMethod.POST)public random_method #2{}

now you can implement your to visit the specific page and another to fill the form.Hope this will help you.


In spring developer can use both RequestMethod.POST and RequestMethod.GET at same controller just making an array of method like that:

@RequestMapping(value = "/esta", method = {RequestMethod.POST, RequestMethod.GET})public String handleRequest(HttpServletRequest request) {//Implementation of your code.}