Can't iterate over list in Jsp

I am using hibernate to get the subjects associated with a particular user. In mainPage, I want to see firstName and LastName (this works) of the user and allowed subjects. But, for some reason, I am not able to successfully iterate over the list of subjects put in mainPage.

In my Spring controller I have a method, which looks like this:

@RequestMapping(value = "/signin", method = RequestMethod.POST)

public String SignIn(@ModelAttribute("user") User user, ModelMap modelMap){

String username = user.getUsername();

String password = user.getPassword();

User user1 = userService.getUser(username, password);

if(user1 != null){

List subjectList = userService.getUserSubjects(user1.getId());

modelMap.addAttribute("subjects", subjectList);

modelMap.addAttribute("user", user1);

return "mainPage";


modelMap.addAttribute("ShowNotAuthenticated", true);


Read More »

By: StackOverFlow - Friday, 9 November

Related Posts