gotch4
gotch4

Reputation: 13299

I can't find a way to access spring model not using EL

I have problem when creating JSPs to use with Spring. I put all my objects in the Model of ModelAndView, it's easy to access them using EL. The problem is to access them from usual <% code %>. Suppose I have a parameter from the model called "foo", is there a way to have it in a variable that I can use in standard Java code in the JSP in a <% %> block?

Upvotes: 2

Views: 3362

Answers (1)

skaffman
skaffman

Reputation: 403581

You'd need to extract it from the request context:

<%
  Object model = request.getAttribute("modelName");
%>

where modelName is the name of the model object in the ModelAndView.

Upvotes: 1

Related Questions