MVC:
To separate core business model functionality from the presentation and control logic that uses this functionality. Such separation allows multiple views to share the same enterprise data model, which makes supporting multiple clients easier to implement, test, and maintain.
Front Controller
Use a controller as the initial point of contact for handling a request. The controller manages the handling of the request, including invoking security services such as authentication and authorization, delegating business processing, managing the choice of an appropriate view, handling errors, and managing the selection of content creation strategies.
DAO(Data Access object)
To abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
如果同時運用這三個application framework,這樣的架構算是很常見。
Pros:
運用struts前端控制器(front controller)來集中管理頁面導引
Struts custom tag來強化 JSP的不足
用Spring將業務邏輯(Service)部份從Struts Action中分離出來,Action只負責收集使用者輸入與傳送頁面所需資料。
業務邏輯部份比較複雜可以單獨在不需要載入application server的情況下進行測試,可測試性提高。
Cons:
同時運用3種framework,對團隊的技術能力門檻較高。
Future:
因為單純使用 JSP 與 tag仍是server端的方式,會使互動性較差,應整合Ajax技術如ZK等Java framework,不需額外學習其他語言。
使用Spring 的MVC module取代Struts可以減少一個framework使用。
留言