Spring 3 MVC - how to turn a form into a query string?

Posted by caerphilly on Stack Overflow See other posts from Stack Overflow or by caerphilly
Published on 2010-03-23T16:58:00Z Indexed on 2010/03/24 9:23 UTC
Read the original article Hit count: 320

Filed under:
|

I have a simple Spring form that gets bound to a form object on post. The http POST handler does some work, and then needs to redirect to a new URL, passing the form data as querystring parameters.

So, assuming I have a form backing object with properties "param1" and "param2", I want to build a string that looks something like this:

redirect:/app/new/page?param1=value;param2=value

Now, Spring will automatically bind values FROM a querystring or a form post into my form object, but I want to GENERATE a querystring with values taken from the form object.

Obviously it's trivial to do this manually but since I'm going to have lots of different form backing objects, is there some built-in facility in Spring to generate a query string from a form object, suitable for building into a URL?

Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring-mvc