计算机科学与技术毕业设计(论文)外文翻译.doc
《计算机科学与技术毕业设计(论文)外文翻译.doc》由会员分享,可在线阅读,更多相关《计算机科学与技术毕业设计(论文)外文翻译.doc(29页珍藏版)》请在三一文库上搜索。
1、本科毕业设计(论文)外文翻译(附外文原文) 系 ( 院 ): 信息科学与工程学院 课题名称: 学生信息管理系统 专业(方向):计算机科学与技术(应用)7.1 Enter ActionMappingsThe Model 2 architecture (see chapter 1) encourages us to use servlets and Java-Server Pages in the same application. Under Model 2, we start by calling a servlet.The servlet handles the business logic
2、 and directs control to the appropriate pageto complete the response.The web application deployment descriptor (web.xml) lets us map a URL patternto a servlet. This can be a general pattern, like *.do, or a specific path, likesaveRecord.do.Some applications implement Model 2 by mapping a servlet to
3、each businessoperation. This approach works, but many applications involve dozens or hundredsof business operations. Since servlets are multithreaded, instantiating so manyservlets is not the best use of server resources. Servlets are designed to handle anynumber of parallel requests. There is no pe
4、rformance benefit in simply creatingmore and more servlets.The servlets primary job is to interact with the container and HTTP. Handlinga business operation is something that a servlet could delegate to another component.Struts does this by having the ActionServlet delegate the business operationto
5、an object. Using a servlet to receive a request and route it to a handler is knownas the Front Controller pattern Go3.Of course, simply delegating the business operation to another componentdoes not solve the problem of mapping URIs W3C, URI to business operations.Our only way of communicating with
6、a web browser is through HTTP requests andURIs. Arranging for a URI to trigger a business operation is an essential part ofdeveloping a web application.Meanwhile, in practice many business operations are handled in similar ways.Since Java is multithreaded, we could get better use of our server resou
7、rces if wecould use the same Action object to handle similar operations. But for this towork, we might need to pass the object a set of configuration parameters to usewith each operation.So whats the bottom line? To implement Model 2 in an efficient and flexibleway, we need to:Enter ActionMappings 1
8、95_ Route requests for our business operations to a single servlet_ Determine which business operation is related to the request_ Load a multithreaded helper object to handle the business operation_ Pass the helper object the specifics of each request along with any configurationdetail used by this
9、operationThis is where ActionMappings come in.7.1.1 The ActionMapping beanAn ActionMapping (org.apache.struts.action.ActionMapping) describes howthe framework handles each discrete business operation (or action). In Struts,each ActionMapping is associated with a specific URI through its path propert
10、y.When a request comes in, the ActionServlet uses the path property to select thecorresponding ActionMapping. The set of ActionMapping objects is kept in anActionMappings collection (org.apache.struts.action.ActionMappings).Originally, the ActionMapping object was used to extend the Action objectrat
11、her than the Action class. When used with an Action, a mapping gives a specificAction object additional responsibilities and new functionality. So, it was essentiallyan Action decorator Go4. Along the way, the ActionMapping evolved into anobject in its own right and can be used with or without an Ac
12、tion.DEFINITION The intent of the decorator pattern is to attach additional responsibilities toan object dynamically. Decorators provide a flexible alternative to subclassingfor extending functionality Go4.The ActionMappings are usually created through the Struts configuration file.For more about th
13、is file, see chapter 4.7.1.2 The ActionMappings catalogThe ActionMappings catalog the business logic available to a Struts application.When a request comes in, the servlet finds its entry in the ActionMappings catalogand pulls the corresponding bean.The ActionServlet uses the ActionMapping bean to d
14、ecide what to do next. Itmay need to forward control off to another resource. Or it may need to populateand validate an ActionForm bean. At some point, it may have to pass control to anAction object, and when the Action returns, it may have to look up an Action-Forward associated with this mapping.1
15、96 CHAPTER 7Designing with ActionMappingsThe ActionMapping works like a routing slip for the servlet. Depending onhow the mapping is filled out, the request could go just about anywhere.The ActionMappings represent the core design of a Struts application. If youwant to figure out how a Struts applic
16、ation works, start with the ActionMappings. Ifyou want to figure out how to write a new Struts application, start with the Action-Mappings. The mappings are at the absolute center of every Struts application.In this chapter, we take a close look at the ActionMapping properties andexplore how they he
17、lp you design the flow of a Struts application.1.0 vs 1.1 In Struts 1.1, ActionMapping subclasses ActionConfig (org.apache.struts.config.ActionConfig) and adds API methods required forbackward compatibility. ActionMapping is not deprecated, and how thehierarchy will be handled in future releases has
18、 not been determined.For now, we refer to the ActionMapping class, but you should note thatin Struts 1.1 all of the action properties are actually defined by the ActionConfigsuper class. The ActionMapping class otherwise works thesame way in both versions.7.2 ActionMapping propertiesTable 7.1 descri
19、bes the base ActionMapping properties. As with other configurationcomponents, developers may extend ActionMapping to provide additionalproperties.Table 7.1 The base ActionMapping propertiesProperty Descriptionpath The URI path from the request used to select this mapping. (API command)forward The co
20、ntext-relative path of the resource that should serve this request via a forward.Exactly one of the forward, include, or type properties must be specified.orinclude The context-relative path of the resource that should serve this request via aninclude. Exactly one of the forward, include, or type pr
21、operties must bespecified.ortype Optionally specifies a subclass of org.apache.struts.action.ActionMappingthat should be used when instantiating this mapping.className The fully qualified name of the Action class used by this mapping.SinceStruts 1.1ActionMapping properties 197In the sections that fo
22、llow, we take a look at each of these properties.7.2.1 The path propertyThe ActionMapping URI, or path, will look to the user like just another file onthe web server. But it does not represent a file. It is a virtual reference to ourActionMapping.Because it is exposed to other systems, the path is n
23、ot really a logical name, likethose we use with ActionForward. The path can include slashes and an extensionas if it referred to a file systembut they are all just part of a single name.The ActionMappings themselves are a “flat” namespace with no type of internalhierarchy whatsoever. They just happe
24、n to use the same characters that we areused to seeing in hierarchical file systems.name The name of the form bean, if any, associated with this action. This is not the classname. It is the logical name used in the form bean configuration.roles The list of security roles that may access this mapping
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机科学 技术 毕业设计 论文 外文 翻译
链接地址:https://www.31doc.com/p-3970338.html