I have a simple controller with scope annotation.
@Controller
@Scope("session")
@RequestMapping("/")
public class HelloController {
private User user = new User("Bob");
@RequestMapping(method = RequestMethod.GET)
public String printWelcome() {
return "hello";
}
}
and simple jsp page
<html>
<body>
<h1>Y=${sessionScope.user}</h1>
<h1>Z=${user}</h1>
</body>
</html>
But when I'm trying to run this code, I'm getting nothing. The result is empty. I don't want to use single beans of User
, also I don't like to pass object of HttpSession
to method in controller or HttpServletRequest
object for retrieving session from it. Is there any solution for using some annotation (except @SessionAttributes
) to pass object to jsp from my controller?