Announcement Announcement Module
Collapse
No announcement yet.
Model Objects Not Resolving in JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Model Objects Not Resolving in JSP

    Hello;

    I am in the process of learning annotations and a few other features of Spring 2.5. Maybe in the process of learning this stuff I have misconfigured something. Or maybe I am just doing something wrong altogether.

    The situation I am running into is objects I am putting into my Model in my controller are not evaluating in my JSP. I have done this before without issue, I am not sure what I am doing wrong this time.

    Here is my method I am calling in my controller:
    Code:
    @RequestMapping("/test.do")
    	public ModelAndView test(HttpServletRequest request,HttpServletResponse response) throws ServletRequestBindingException  {
    		ModelAndView mav = new ModelAndView("test");
    		mav.addObject("testModel", "hi there i am in a model");
                    return mav;
    }
    In my JSP I have this:

    Code:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE html 
         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
         
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    	<body>
    		<p>${testModel}</p>
    	</body>
    </html>
    When I call the URL I just get "${testModel}" written out. It seems no matter what I put in here I just get it written back out without being evaluated.

    Any ideas what I am doing wrong.

    Thanks,

    Luke

  • #2
    What happens if you instead write that out with a "c:out" tag?

    Is your web.xml correctly encoded with a schema reference, instead of a DTD?

    Comment


    • #3
      Great call! It was the web.xml, I had the DTD not the schema.

      Thanks!

      Comment

      Working...
      X