英语翻译How Many Controller Servlets?There is a debate among MVC proponents about how many controller servlets an application should have.Should we use one servlet for each type of request (as in the template selection servlet approach),or a sing

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/24 19:50:56

英语翻译How Many Controller Servlets?There is a debate among MVC proponents about how many controller servlets an application should have.Should we use one servlet for each type of request (as in the template selection servlet approach),or a sing
英语翻译
How Many Controller Servlets?
There is a debate among MVC proponents about how many controller servlets an application should have.Should we use one servlet for each type of request (as in the template selection servlet approach),or a single front controller that handles all requests to an application or subsystem?Core J2EE Patterns terms the latter approach the Multiplexed Resource Mapping Strategy.If we use a single front controller,it should be generic,and should forward requests to a number of sub-controllers.
Many of the arguments against using a single controller servlet are unsound - such as the idea that it introduces a single point of failure (threads can die,not objects); or that it means that the controller will be too large (we can use a generic controller with many application-specific delegates,rather than one huge,all-knowing controller).One valid criticism is the need to duplicate the standard mapping of URL to request-handling class.While we can map URLs directly onto servlets in web.xml,when we use one controller to front many URLs we will usually map all URLs onto the controller,which must then use its own mapping format to route URLs among its sub-controllers.However,this isn't a real problem in practice.
The advantages of using a single controller include that it ensures consistency of control flow - for example,ensuring that necessary resources are available to all sub-controllers.It also means that each sub-controller doesn't have to be a servlet; an important point as we can allow sub-controllers to implement a less complex interface.
It's natural to ask what the performance implications are of the additional overhead in funneling requests through a single controller.A typical controller servlet implementation will need to do hash table lookups based on the URL of each request.Some frameworks use reflection (although an efficient framework should cache the results of reflection).Fortunately,the performance impact is negligible.Pretty much anything we do once per request will have no measurable effect on the overall performance of a web application.In profiling applications running in MVC frameworks,I've consistently found the framework overhead to be insignificant - even undetectable.
All the real frameworks I know of use a single controller servlet for a whole application or a set of related use cases.The controller servlet then delegates work to helper classes that implement a framework-specific interface or extend a base class provided by the framework.

英语翻译How Many Controller Servlets?There is a debate among MVC proponents about how many controller servlets an application should have.Should we use one servlet for each type of request (as in the template selection servlet approach),or a sing
有多少控制器/ Servlets
有一个辩论的MVC倡议者多少控制器/ Servlets的应用应该有.我们是否应该使用一个Servlet的为每个类型的要求(如在模板选择Servlet的做法) ,或一个单一的前端控制器,处理所有的请求的应用程序或子系统?J2EE的核心模式而言,后者的做法,复用资源映射策略.如果我们用一个单一的前端控制器,它应该是通用的,并应提出要求的若干小组控制器.
很多的论据,反对使用一个单一的控制器的Servlet是不健全的-如的想法,它介绍了一种单点故障(线程可以死,而不是对象) ;或认为,这意味着,该控制器将过大,(我们可以使用通用控制器与许多特定应用的代表,而非一个庞大的,全知控制器) .一个有效的批评是需要重复的标准映射的网址,要求处理类.虽然我们可以地图网址,直接上/ Servlets在web.xml ,当我们用一个控制器向前线很多的网址,我们通常会地图上的所有网址,控制器,它必须然后使用自己映射格式,以路线的网址之间及其分控制器.不过,这不是一个真正的问题,在实践中.
的优势,使用一个单一的控制器,包括它确保一致性控制流-例如,确保必要的资源提供给所有小组控制器.这也意味着,每个子控制器,并不一定要一个servlet ;重要的一点,因为我们可以让小组控制器,以实施一项不太复杂的界面.
它的自然要问什么表现的影响的额外开销,在引导的要求,通过一个单一控制器.一个典型的控制器Servlet的实施将需要做的哈希表查找的基础上,网址每个请求.一些框架使用反射(虽然一个有效率的框架应缓存的结果,反映了) .所幸的是,对性能的影响是微不足道的.几乎什么,我们做每一次的要求,不会有任何可衡量的影响,整体表现Web应用程序.在剖面上运行的应用程序在MVC的框架,我已经发现,一贯的框架内,开销不大-甚至u ndetectable.
所有真正的框架,据我所知,使用一个单一的控制器的Servlet ,为整个应用或一组相关的用例.控制器的Servlet ,然后代表工作助理班,实施一个框架,具体的界面,或延长基类所提供的框架.
有的你打错了,没有这个词!

这么长谁给你翻啊?自己去GOOGLE一下,然后整理一下就好了哇。