Results 1 to 2 of 2

Thread: Does view template has implicit request object?

  1. #1
    Join Date
    Dec 2007
    Posts
    10

    Default Does view template has implicit request object?

    I have a Spring MVC TestController in which I'm setting a request attribute. I'm using velocity template for rendering the views.

    @RequestMapping(value="/test", method=RequestMethod.GET)
    public ModelAndView display(HttpServletRequest req, HttpServletResponse resp){
    ...
    req.setAttribute("req1", "This should be present for first request");
    ...
    }
    In the velocity template I'm doing something like

    Request: $request.getAttribute('req1')
    but I'm not getting the value of req1. I know I should have put req1 in model map instead of request but I want to know about implicit request object ref.

    I tried $req1 as well but its not working.

    When I'm doing the same thing with the model and returning it back, everything is working correctly.

    Where am I going wrong?

    Thanks.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Please use [ code][/code ] tags when posting code...

    You have 2 different requests and parameters are destroyed once the request is over. As stated by yourself use the model(map) and try to leave the request/response behind.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

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