引用:http://www.javaworld.com/javaworld/jw-01-2002/jw-0104-tilestrut.html
【程序编程相关:DOM4J 使用简介(转)】 【推荐阅读:使用属性和反射过渡从数据存取层到业务物件】 【扩展信息:Socket编程之Connect超时】advertisement
ypically during web application development, the user interface (ui) group creates the site´s look and feel. based on that look and feel, the group creates html pages that represent the application´s functionality and navigation. with a servlets and javaserver pages (jsps)-based implementation, where html pages are converted into servlets and jsps, ui developers identify common html and jsp view components, such as header, footer, body, menu, and search. this article presents various solutions to effectively and efficiently organize html and jsp view components. i evaluate each solution using specific criteria, such as page number, code repetition, and layout control.
to explore templating and layout solutions, we will use the tiles framework. the tiles framework´s view components are known as tiles. the framework uses an xml configuration file to organize those tiles. this framework not only enables you to reuse tiles, but also the layouts that organize them.
to explore the more powerful and flexible solutions, we will investigate the synergy between the tiles and struts frameworks. struts is an open source framework for developing web applications using the popular model-view-controller (mvc) or model 2 architectural pattern. struts comes with a large set of reusable tags for which the tiles tag library makes an excellent enhancement.
evaluation criteria
i will evaluate each solution based on the criteria below. the criteria are not mutually exclusive. for a specific situation and particular application, you must always balance between the strengths and weaknesses of each solution with respect to these factors.page number
a solution should strive to minimize the number of html and jsp pages. as the page number increases, the complexity of developing, managing, and maintaining an application increases drastically.code repetition
under most circumstances, repetition is bad. the more repeated html and jsp code, the more difficult it is to develop and maintain an application. a simple change can result in a cascade of changes in many different pages with unpredictable consequences. a concrete and practical way of attaining reuse is to avoid code repetition.layout control
while code repetition is bad, repetition of layout logic and code can be worse. spreading the logic and behavior of view component organization over several jsps can be a recipe for disaster. attaining reuse of templating and layout logic is a better form of reuse than only reusing view components. thus, you can achieve a higher level of reuse with effective layout control.coupling
coupling is the degree of interactivity between entities. software engineers are taught again and again to minimize coupling between unrelated classes, packages, and so on. we can apply the same principle to view components. even though there are distinct view components from a user perspective, in the jsp implementation, the components might be intricately coupled. a solution should reduce coupling between unrelated view components.complexity
... 下一页