WEB开发网
开发学院WEB开发Jsp 1. Introduction 阅读

1. Introduction

 2008-01-05 18:34:07 来源:WEB开发网   
核心提示:1. Introduction 介绍1.1 Forward into the Past! (or a brief history of Struts)回顾过去!(Struts简史)When java servlets were first invented, many PRogrammers quickly reali

1. Introduction 介绍

1.1 Forward into the Past! (or a brief history of Struts)回顾过去!(Struts简史)

When java servlets were first invented, many PRogrammers quickly realized that they were a Good Thing. They were faster and more powerful that standard CGI, portable, and infinitely extensible.
当JavaServlets第一次出现时,许多程序员很快意识到那是一个好东西。比标准CGI更快速、更强大、轻便,可以无限扩展。

But writing Html to send to the browser in endless println() statements was tiresome and problematic. The answer to that was JavaServer Pages, which turned Servlet writing inside-out. Now developers could easily mix HTML with Java code, and have all the advantages of servlets. The sky was the limit!
但是在向浏览器输出HTML语句需要写不断地写println()语句,这实在是一件令人厌倦和麻烦的事。

Java web applications quickly became "jsp-centric". This in-and-of itself was not a Bad Thing, but it did little to resolve flow control issues and other problems endemic to web applications.

Another model was clearly needed ...

Many clever developers realized that JavaServer Pages AND servlets could be used together to deploy web applications. The servlets could help with the control-flow, and the JSPs could focus on the nasty business of writing HTML. In due course, using JSPs and servlets together became known as Model 2 (meaning, presumably, that using JSPs alone was Model 1).

Of course, there is nothing new under the Sun ... and many have been quick to point out that JSP's Model 2 follows the classic Model-View-Controller design pattern abstracted from the venerable Smalltalk MVC framework. Java Web developers now tend to use the terms Model 2 and MVC interchangeably. In this guide, we use the MVC paradigm to describe the Struts architecture, which might be best termed a Model 2/MVC design.

The Struts project was launched in May 2000 by Craig R. McClanahan to provide a standard MVC framework to the Java community. In July 2001, Struts 1.0 was released, and IOHO, Java Model 2 development will never be quite the same.

1.2 The Model-View-Controller ('MVC') Design Pattern

In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests - in our case, HTTP requests - to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an application's business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make applications significantly easier to create and maintain.

1.2.1 The Model: System State and Business Logic JavaBeans


Tags:Introduction

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接