Announcement Announcement Module
Collapse
No announcement yet.
Does view template has implicit request object? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X