上QQ阅读APP看书,第一时间看更新
How it works...
The main actor in this whole scenario is the Models class injected into the Controller:
@Inject
Models models;
It's a class from MVC 1.0 API that owns the responsibility, in this recipe, of letting the User object be available for the View layer. It's injected (using CDI) and uses another injected bean, userBean, to do it:
models.put("user", userBean.getUser());
So, the View can easily access the values from the User object using expression language:
<h1>${user.name}/${user.email}</h1>