Spring MVC model attribute value not displaying

2019-09-08 11:53发布

问题:

I am having a problem getting some of my model attributes to display.

Here is part of the data I am setting

            spd.email = "testaddr@ser.net";
    spd.birthMonth = "11";
    spd.birthDay = "12";
    spd.birthYear = "2013";

Here is where I add things to the view. sessionID & email are simple Strings. spd is defined above;

           ModelAndView mav = new ModelAndView("signup");
             mav.addObject("sessionID",sessionID);
             mav.addObject("email", email);              
             mav.addObject("SignupPageData",spd); 

Here are the lines in the jsp

            <p>email from spd  ${signuppagedata.email}  </p>
                <p>email ${email} ></p>
                  <p>sessionID ${sessionID} ></p>

both of the simple Strings email & sessionID print fine. signuppagedata.email does not display. What am I doing incorrectly ?

回答1:

I think the model attribute names are case sensitive. Change this

mav.addObject("SignupPageData",spd); 

to

mav.addObject("signupPageData",spd);