To create and differentiate session- and request-based beans, follow these steps:
- This recipe needs some custom models that can be injected into the container: either request-scoped or session-scoped beans. First, let us create a model SalaryGrade in the org.packt.dissect.mvc.model.data package. This model must be injected as a @Bean into the ApplicationContext through the annotation @Component:
@Scope(value=WebApplicationContext.SCOPE_REQUEST, proxyMode=ScopedProxyMode.TARGET_CLASS) @Component public class SalaryGrade { private String grade; private Double rate; private Date date; public SalaryGrade() { date = new Date(); } // getters and setters }
This bean is registered as a request-scoped bean, and since this type of ...