PDA

View Full Version : Model variable not evaluating in JSP


markarnold
May 6th, 2008, 12:12 PM
Hello everybody,

I have a problem with SpringMVC using JSTL JSPs. Controllers and everything else seem to work, but the model objects that I put into the ModelAndView in the controller method are not being evaluated in the JSP.

Here is my Controller:
------------------------------------------------------------------------

public class TestController extends MultiActionController {

public ModelAndView sayHello(HttpServletRequest _req, HttpServletResponse _resp) {
ModelAndView _mv = new ModelAndView("sayHello", "say", "hello");
System.err.println("x='" + _req.getParameter("x") + "'");
return _mv;
}

}
------------------------------------------------------------------------

I put in the 'System.err.println("x=....' to make sure that it does actually call the right method in the right controller, and it does...



Here is my jsp:
------------------------------------------------------------------------

<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<body>
Saying '<c:out value="${say}"/>'...
</body>
</html>

------------------------------------------------------------------------


Here is the HTML source from the browser:
------------------------------------------------------------------------

<html>
<body>
Saying '${say}'...
</body>
</html>
------------------------------------------------------------------------


Does anybody know what my problem is?

This is Spring 2.5.2 on Tomcat 5.0.28 and JDK1.6.0_06

Thanks,

MARK

markarnold
May 6th, 2008, 01:21 PM
In the meantime I upgraded Tomcat to 6.0.16, which has fixed the problem on my test page.

MARK

nata
May 14th, 2008, 08:33 AM
Try without characters - ' - around < c : out > tag.

For example:
<body>
Saying <c:out value="${say}"/>
</body>

markarnold
May 14th, 2008, 10:57 AM
Hello nata,

thanks for your response.
Like I wrote earlier, the problem was the Tomcat version.
Apparently, Tomcat 5.0.x is not doing the right thing.
Everything works fine in 6.0.16.

MARK