Spring - Redirect after POST (even with validation errors)

Posted by Taylor L on Stack Overflow See other posts from Stack Overflow or by Taylor L
Published on 2010-03-30T08:35:06Z Indexed on 2010/05/10 11:24 UTC
Read the original article Hit count: 317

I'm trying to figure out how to "preserve" the BindingResult so it can be used in a subsequent GET via the Spring <form:errors> tag. The reason I want to do this is because of Google App Engine's SSL limitations. I have a form which is displayed via HTTP and the post is to an HTTPS URL. If I only forward rather than redirect then the user would see the https://whatever.appspot.com/my/form URL. I'm trying to avoid this. Any ideas how to approach this?

Below is what I'd like to do, but I only see validation errors when I use return "create".

@RequestMapping(value = "/submit", method = RequestMethod.POST)
public final String submit(
    @ModelAttribute("register") @Valid final Register register,
    final BindingResult binding) {

    if (binding.hasErrors()) {
        return "redirect:/register/create";
    }

    return "redirect:/register/success";
}

© Stack Overflow or respective owner

Related posts about spring

Related posts about google-app-engine