Author
Spring MVC Issue: Passing data to view
Balaji Akella
Ranch Hand
Joined: Oct 29, 2003
Posts: 35
posted Nov 04, 2005 14:10:00
0
I am trying to pass data from the Controller to view (jsp page) using ModelAndView object. Please consider the following code, home.jsp -------- <html> . . <p>${message}</p> . </html> Controller Class ---------------- public class UAMInternalController implements Controller { protected final Log logger = LogFactory.getLog(getClass()); private String greeting = "Namaste!"; . . public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { . . return new ModelAndView("home","message", greeting); } } The view is printing the variable as is, that is, ${message} instead of the contents of the variable "greeting". Please suggest a solution for this problem. Thanks, Swamy SCJP 1.2, SCWCD, SCBCD
In the morning there is hope; in the afternoon, fulfillment; in the evening, memory; at night, peace.
Balaji Akella
Ranch Hand
Joined: Oct 29, 2003
Posts: 35
posted Nov 04, 2005 16:41:00
0
I figured out the problem, but not the reason though.. The JSP was changed to use, JSTL tags, in which case it works. The new JSP file looks something like this: <%@ taglib prefix="core" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> . . <core ut value="${message}"/> . Thanks, Swamy
subject: Spring MVC Issue: Passing data to view