IntelliJ Java IDE
The moose likes Other Application Frameworks and the fly likes Spring MVC Issue: Passing data to view Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Spring MVC Issue: Passing data to view" Watch "Spring MVC Issue: Passing data to view" New topic
Author

Spring MVC Issue: Passing data to view

Balaji Akella
Ranch Hand

Joined: Oct 29, 2003
Posts: 35
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
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
 
IntelliJ Java IDE
 
subject: Spring MVC Issue: Passing data to view
 
Threads others viewed
localisation problems
Hello World with spring, Maven and Tomcat
problem in getting model data from spring controller to jsp
Spring
Spring MVC : {beanName.property} not working
developer file tools