PDA

View Full Version : GET parameters and Velocity context


brianstclair
Sep 25th, 2004, 01:11 PM
I am using a RedirectView from one page, supplying a name/value pair as the model as follows:


View redirect = new RedirectView(getSuccessView());
return new ModelAndView(redirect, "name", "value");


My Velocity template includes the following line:


The value is $name<br>


The name/value pair is being added to the URL (http://localhost:8080/webapp/targetPage.htm?name=value) but is not being added to the Velocity context, so my template displays as "The value is $name", not "The value is value".

I'm assuming that this is by design, I'm just not sure how I can get the name/value pair into the Velocity context so that it is available to the target template. Any help would be appreciated!

Brian

davison
Sep 25th, 2004, 08:27 PM
Velocity itself has no privileged knowledge of the servlet API. The controller that is mapped to 'targetPage.htm' in your example will need to expose the request parameters to the view as model attributes.

Regards,

brianstclair
Sep 25th, 2004, 11:15 PM
Thanks for the quick response, Darren! That's pretty much what I figured - I was hoping I was missing something simple, though. 'Preciate the help.

Brian