Context
The presentation-tier request handling mechanism must control and coordinate
processing of each user across multiple requests. Such control mechanisms may be
managed in either a centralized or decentralized manner.
Problem
The system requires a centralized access point for presentation-tier request handling
to support the integration of system services, content retrieval, view management, and
navigation. When the user accesses the view directly without going through a centralized
mechanism, two problems may occur:
Each view is required to provide its own system services, often resulting in duplicate
code.
View navigation is left to the views. This may result in commingled view content and
view navigation.
Additionally, distributed control is more difficult to maintain, since changes will
often need to be made in numerous places.
Forces
Common system services processing completes per request. For example, the security
service completes authentication and authorization checks.
Logic that is best handled in one central location is instead replicated within
numerous views.
Decision points exist with respect to the retrieval and manipulation of data.
Multiple views are used to respond to similar business requests.
A centralized point of contact for handling a request may be useful, for example, to
control and log a user's progress through the site.
System services and view management logic are relatively sophisticated.
Solution
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.
The controller provides a centralized entry point that controls and manages Web
request handling. By centralizing decision points and controls, the controller also helps
reduce the amount of Java code, called scriptlets, embedded in the JavaServer Pages (JSP)
page.
Centralizing control in the controller and reducing business logic in the view
promotes code reuse across requests. It is a preferable approach to the
alternative-embedding code in multiple views-because that approach may lead to a more
error-prone, reuse-by-copy- and-paste environment.
Typically, a controller coordinates with a dispatcher component. Dispatchers are
responsible for view management and navigation. Thus, a dispatcher chooses the next view
for the user and vectors control to the resource. Dispatchers may be encapsulated within the
controller directly or can be extracted into a separate component.
While the Front Controller pattern suggests centralizing the handling of all requests,
it does not limit the number of handlers in the system, as does a Singleton. An application
may use multiple controllers in a system, each mapping to a set of distinct services.
- 浏览: 15351 次
- 性别:
- 来自: 北京
文章分类
最新评论
发表评论
-
集成层模式:Service Activator—服务激发器模式
2014-04-09 20:31 1106ContextEnterprise beans and o ... -
集成层模式:Data Access Object—数据访问对象模式
2014-04-09 20:31 532ContextAccess to data varies ... -
业务层模式:Service Locator—服务定位器模式
2014-04-09 20:31 1166ContextService lookup and cre ... -
表示层模式:Value List Handler—值列表处理器模式
2014-04-09 20:32 770ContextThe client requires a ... -
表示层模式:Transfer Object Assembler—传输对象组装器模式
2014-04-10 22:48 756ContextIn a Java 2 Platform, ... -
业务层模式:Composite Entity—复合实体模式
2014-04-08 21:38 497ContextEntity beans are not i ... -
业务层模式:Session Facade—会话门面模式
2014-04-08 21:38 423ContextEnterprise beans encap ... -
业务层模式:Transfer Object—传输对象模式
2014-04-08 21:37 434ContextApplication clients ne ... -
业务层模式:Business Delegate—业务委托模式
2014-04-08 21:37 983ContextA multi-tiered, distri ... -
表示层模式:Dispatcher View—分发者视图模式
2014-04-08 21:37 543ContextSystem controls flow o ... -
表示层模式:Service to Worker—工作者服务模式
2014-04-07 10:48 988ContextThe system controls flow ... -
表示层模式:Composite View—复合视图模式
2014-04-07 10:41 490ContextSophisticated Web page ... -
表示层模式:View Helper—视图助手模式
2014-04-07 10:37 1028ContextThe system creates pre ... -
表示层模式:Intercepting Filter—拦截过滤器模式
2014-04-07 10:29 627Context The presentati ...
相关推荐
创建型模式 ...前端控制器模式(Front Controller Pattern) 拦截过滤器模式(Intercepting Filter Pattern) 服务定位器模式(Service Locator Pattern) 传输对象模式(Transfer Object Pattern)
8. 前端控制器模式(Front Controller):此模式将所有的请求处理都集中在一个控制器中处理,这个控制器负责拦截所有的请求并分发给相应的处理程序。在J2EE中,Servlet可以看作是前端控制器的一个实现。 9. 代理...
例如,`FrontController`(前端控制器)模式将Servlet代码的开发转化为了在图形用户界面下的开发。需要注意的是,J2EE设计模式解决了J2EE项目中最常见的问题。如果你遇到的问题非常特殊,很可能找不到相应的设计模式...
8. **前端控制器(Front Controller)模式**:例如Servlet,负责处理所有来自客户端的请求,进行集中控制和调度。 9. **视图助手(View Helper)模式**:为JSP页面提供辅助对象,以保持视图与模型的分离,减少JSP...
它遵循了多种著名的设计模式,包括ActiveRecord(活动记录)、Association Data Mapping(关联数据映射)、Front Controller(前端控制器)和Model-View-Controller(模型-视图-控制器,简称MVC)模式。CakePHP旨在...
#### 前端控制器模式(Front Controller Pattern) 前端控制器模式定义了一个单一的控制器对象来接收所有的请求,然后分发给合适的处理程序。 #### 拦截过滤器模式(Intercepting Filter Pattern) 拦截过滤器...
- **前端控制器(Front Controller)**:如JSF的FacesServlet,处理所有请求,统一应用逻辑。 4. **J2EE的并发与事务管理**: - **线程安全**:在多线程环境下,正确处理共享资源以避免数据不一致。 - **事务...
5. **前端控制器(Front Controller)**:在Web应用中,前端控制器模式负责处理所有请求,调度业务逻辑,简化视图层的复杂性。 6. **模型-视图-控制器(Model-View-Controller, MVC)**:MVC模式是用于构建用户界面的...
- **中央控制器(Front Controller)**:Struts框架中的`ActionServlet`作为前端控制器,负责接收所有请求,解析URL,并转发到对应的`Action`类进行处理。 - **Action**:业务控制器,执行具体的业务逻辑,返回一...
Struts2 作为 Web MVC 框架,采用了一种更新的 MVC 实现,即前端控制器(Front Controller)模式。在这个模式中,所有的 HTTP 请求都会先经过一个全局的 Servlet 分发器,即 Struts2 的 ActionServlet,它负责解析...
框架提供了一组设计模式,如Front Controller(前端控制器)、Action和ActionForm,用于构建企业级Web应用程序。 2. **核心组件**: - **Front Controller(Struts Controller)**:Servlet `org.apache.struts....
1. **前控制器(Front Controller)**:前控制器模式提供了一个统一的入口点来处理所有进入系统的请求。它负责分发请求到合适的处理器,并且处理诸如认证、日志记录等全局性的任务。这种方式有助于简化前端代码,避免...
它负责接收前端控制器的请求,并将其分发给合适的处理器(Controller)。`DispatcherServlet`是SpringMVC的核心组件之一,用于初始化上下文和处理HTTP请求。当客户端发起请求时,请求会被`DispatcherServlet`拦截,...
5. **控制层**:书中讨论了前端控制器(Front Controller)模式,它集中处理所有请求,简化了系统架构。同时,书中也提到了拦截过滤器(Interceptor Filter)模式,用于在请求处理前进行预处理或后处理。 6. **企业...
前端控制器模式,如Struts或Spring MVC,提供一个统一的入口点来处理所有用户请求,然后转发到适当的处理组件。 7. Inversion of Control (IoC) / Dependency Injection (DI) IoC和DI是控制反转和依赖注入的简称,...
2. **Front Controller(前端控制器)**:该模式提供了一个中心控制点来处理所有的客户端请求,通过统一的入口点可以方便地添加通用处理逻辑,如日志记录,而无需在每个业务组件中重复相同的代码。 ### 知识点三:...
6. **设计模式**:考虑到“jsp设计软件源码”,开发者可能采用了某种设计模式,如Model-View-Controller (MVC) 或 Front Controller,以提高代码的可读性和可维护性。 7. **部署与运行**:源代码需要在支持JSP和...
- **Struts2**:负责前端控制器(Front Controller)和视图(View)的处理,通过Action类接收请求并调用Service层进行业务处理,然后返回结果到对应的JSP页面。 - **Spring**:提供依赖注入(DI)和面向切面编程...
`com.entity.view`、`com.model`和`com.service`、`com.service.impl`这些目录可能分别对应视图、模型和控制器层。 3. **实体类(Entity)**:`com.entity.view`下的类可能是用来表示数据库中的表或对象,用于封装...