Page Controller页面控制器实现
2014-01-26 21:19 youxin 阅读(911) 评论(0) 编辑 收藏 举报A Page Controller is one object or file declaration designed to handle the request for one logical web page or action.
With a simple mapping between a page request (URL) and files, this is the default pattern for scripting solutions (PHP, ASP, JSP). A single file handles the request for a specific page. This simple mechanism mirrors how static web pages are handled.
Scripting solutions provide a poor separation between the view and the controller when implementing a Model View Controller architecture. This can make testing and reuse difficult. Also See Template View for separating the View from other application logic.
The primary responsibility of the page controller as part of Model View Controller is to process input and coordinate the model and the view. The page controller extracts information from the web server request and invoke an action on the model or calls a view based on that information. Page controller is distinguished from a Front Controller in that the page controller operates on only a single logical page, where aFront Controller performs this functions for a set of logical pages.
页面控制器紧紧操作一个逻辑页面,而前端控制器则操作一系列页面。
Page Controllers are useful on web sites with static navigation structures.
Base Controller
When multiple page controllers share duplicate logic, a common practice is to move that logic to a base page controller which each page controller can inherit from. This is one way of implementingCentralized Request Logic.
ASP.NET provides a special mechanism for implementing base controllers in scripts, called Code Behind.
When the base controller class begins to have special case logic in it for types of requests, it might be a good idea to consider a Front Controller instead.
当多个页面控制器拥有共同的逻辑时,一个常见的经验就是把共同逻辑移到base page controller,页面控制器继承基类。这是实现集中请求逻辑的方式。
当base controller开始对不同的请求有不同的处理逻辑时,这是考虑前段控制器是一个好主意,
上面转自:http://www.phpwact.org/pattern/page_controller
martin fowler解释:
page controller: An object that handles a request for a specific page or action on a Web site.
Most people's basic Web experience is with static HTML pages. When you request static HTML you pass to the Web server the name and path for a HTML document stored on it. The key notion is that each page on the Web site is a separate document on the server. With dynamic pages things can get much more interesting since there's a much more complex relationship between path names and the file that responds. However, the approach of one path leading to one file that handles the request is a simple model to understand.
As a result, Page Controller has one input controller for each logical page of the Web site. That controller may be the page itself, as it often is in server page environments, or it may be a separate object that corresponds to that page.
参考:http://www.martinfowler.com/eaaCatalog/pageController.html
更多:http://www.onlamp.com/pub/a/php/2004/10/14/page_controller.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2012-01-26 php处理checkbox