Results 1 to 3 of 3

Thread: GET parameters and Velocity context

  1. #1
    Join Date
    Sep 2004
    Posts
    19

    Default GET parameters and Velocity context

    I am using a RedirectView from one page, supplying a name/value pair as the model as follows:

    Code:
    View redirect = new RedirectView(getSuccessView());
    return new ModelAndView(redirect, "name", "value");
    My Velocity template includes the following line:

    Code:
    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

  2. #2
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    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,
    Darren Davison.
    Public Key: 0xE855B3EA

  3. #3
    Join Date
    Sep 2004
    Posts
    19

    Default

    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

Similar Threads

  1. FreeMarker vs Velocity
    By Martin Kersten in forum Architecture
    Replies: 8
    Last Post: May 30th, 2005, 09:21 AM
  2. How to use themes with velocity?
    By fsamir in forum Web
    Replies: 0
    Last Post: Apr 27th, 2005, 01:42 PM
  3. accessing GET parameters?
    By jbetancourt in forum Web
    Replies: 2
    Last Post: Apr 14th, 2005, 10:38 AM
  4. Replies: 1
    Last Post: Dec 25th, 2004, 06:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •