Spring MVC Controller redirect using URL parameters instead of in response.
Posted
by predhme
on Stack Overflow
See other posts from Stack Overflow
or by predhme
Published on 2010-03-23T14:17:48Z
Indexed on
2010/03/23
14:33 UTC
Read the original article
Hit count: 749
I am trying to implement RESTful urls in my Spring MVC application. All is well except for handling form submissions. I need to redirect either back to the original form or to a "success" page.
@Controller
@RequestMapping("/form")
public class MyController {
@RequestMapping(method = RequestMethod.GET)
public String setupForm() {
// do my stuff
return "myform";
}
@RequestMapping(method = RequestMethod.POST)
public String processForm(ModelMap model) {
// process form data
model.addAttribute("notification", "Successfully did it!");
return "redirect:/form";
}
}
However as I read in the Spring documentation, if you redirect any parameters will be put into the url. And that doesn't work for me. What would be the most graceful way around this?
© Stack Overflow or respective owner