- Jakarta EE Cookbook
- Elder Moraes
- 83字
- 2025-02-26 04:14:00
How it works...
The main actor in this whole scenario is the Models class injected into the Controller, shown as follows:
@Inject
Models models;
It's a class from MVC 1.0 API that has the responsibility, in this recipe, of letting the User object to 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 as follows:
<h1>${user.name}/${user.email}</h1>