Decoupling view from the controller, Decoupling – HP Integrity NonStop J-Series User Manual
Page 100

Figure 27 EmpInfo: Employee Details Screen
Decoupling View from the Controller
So far, the controller is specifying full path of the view, thereby creating unnecessary dependency
between the controller and the view. Ideally, the view must be mapped using a logical name, so
that the view can be switched without changing the controller.
To decouple the view from the controller, complete the following steps:
1.
Modify the EmpInfo-servlet.xml file in the EmpInfo/WebContent/WEB-INF directory
to add the following bean to declare a new ViewResolver entry.
After modification, the EmpInfo-servlet.xml file appears as:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
2.
Modify the EmployeeController class EmpInfo/com/hp/empinfo/web/
EmployeeController.java
to decouple the controller from view using ViewResolver
, as shown below:
Before modification:
100 Getting Started with Spring