Alex Rivera | Logout

how to access a ModelAndView object within the jsp page

Asked 2010-09-17T17:40:43.290
21

I have a code like this in my controller.

ModelAndView result = new ModelAndView("person/sometrends");  
result.addObject("data", data);  // data -> Map

In my JSP page I have written some Java code that is dependent on the data object. How can I get that data object within the JSP code?

I tried something like this (pseudo code).

<%
    Map x = ${data};
%>

But that doesn't work. Not sure how to access it.

Edit
Report

2 Answers

4

Try this:

request.getAttribute("data")
answered 2010-10-25T16:22:26.157
2

try<% String username = (String)request.getAttribute("data"); %>

answered 2012-04-13T05:41:07.137

Your Answer