站内搜索: 请输入搜索关键词
当前页面: 图书首页 > JavaServer Pages, Second Edition

JavaServer Pages, Second Edition

[ directory ] Previous Section Next Section

Chapter 12. The Controller

So far, little has been said about the controller side of the model/view/controller paradigm. One reason is that a great deal can be done without a formal controller. Without a model, there would be nothing to show; without a view, there would be no way to show it. But so far, it has been possible to muddle along by putting controller functionality into one of the other layers. After all, the whole Java News Today site was built without a controller. The site has been able to get away with this only because the models and views have been pretty closely matched. Most of Java News Today's pages have had a one-to-one correspondence among page elements, form fields, bean properties, and database fields.

The second, and more relevant, reason that controllers have not yet been discussed is that it would have been impossible to do so without a thorough knowledge of Java. No special JSP tags or similar building blocks can be used to build a controller; they must be hand built in Java. Fortunately, an excellent framework simplifies the task of building such controllers.

It was also necessary to understand bean implementations and servlets, as controllers will mediate between user actions controlled by servlets and JSPs梬hich are themselves servlets梐nd beans. Therefore, the Java code that comprises the controller must be able to interface with both of these APIs.

    [ directory ] Previous Section Next Section