@Controller
@RequestMapping("/")
@Scope("session")
public class HomeController {
private String sessionUser;
public void setSessionUser(String sessionUser) {
this.sessionUser = sessionUser;
}
public String getSessionUser() {
return this.sessionUser;
}
@RequestMapping(value = { "/profile" }, method = RequestMethod.GET)
public String profilePage(Model model, HttpServletRequest req, HttpServletResponse res)
{
User session = (User) req.getSession().getAttribute("name");
if(session != null)
{
model.addAttribute("userInfo", "mklyohngsd");
return "profile";
}else
model.addAttribute("userInfo", "logged out!!");
return "home";
}
}
want to print userinfo in my server console,this model.addAttribute() is not working
In jsp pages i used ${userinfo} to print,but its only printing {userinfo} not the details.
I am new to jsp and spring please help.