-
Sep 30th, 2011, 11:11 AM
#1
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.
-
Oct 3rd, 2011, 02:35 AM
#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.
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
-
Forum Rules