Java语言的优点 毕业论文外文翻译.doc

上传人:小小飞 文档编号:3901965 上传时间:2019-10-09 格式:DOC 页数:13 大小:57.02KB
返回 下载 相关 举报
Java语言的优点 毕业论文外文翻译.doc_第1页
第1页 / 共13页
Java语言的优点 毕业论文外文翻译.doc_第2页
第2页 / 共13页
Java语言的优点 毕业论文外文翻译.doc_第3页
第3页 / 共13页
Java语言的优点 毕业论文外文翻译.doc_第4页
第4页 / 共13页
Java语言的优点 毕业论文外文翻译.doc_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《Java语言的优点 毕业论文外文翻译.doc》由会员分享,可在线阅读,更多相关《Java语言的优点 毕业论文外文翻译.doc(13页珍藏版)》请在三一文库上搜索。

1、中文译文Java是灸手可热的Internet软件技术中的一种,而这些技术孕育了World Wide Web、内部网一类令人生畏的词儿以及名片上和电视广告中那些怪模怪样的地址。最初,它是以一种利用图形动画来活跃Web页面的一种方法闻名,例如,股票报价从屏幕上慢慢移动和跳跃的图标,Java很快全面介入。令微软公司惊愕的是,它很快成了一种被称作计算平台的东西-一个能让程序员开发应用软件的坚实基础。Java正在使快速开发Internet上通信与协同工作的通用程序成为可能。这里,我们不仅是谈论字处理、电子数据表,而且是能够处理销售、客户服务、记帐、数据库和人事资源管理的应用程序-它们是公司计算的基础。J

2、ava也使争论中的一类新的称之为网络计算机(即PC)的便宜计算机成为可能,SUN、IBM、Oracle、Apple和其它公司希望这种计算机将在公司和家庭中普及开来。Java工作的方法简单。与那些要占用PC机硬盘多兆字节的普通应用软件不一样,Java应用程序,即小应用程序,是很小的程序,它常驻在网络中集中式的服务器上。只有当你需要这种应用程序时,网络才把它们送到你的机器上;由于小应用程序比常规程序小得多,故下载不需很多时间。比方说,你要检查一下西南地区的销售结果。利用Internet浏览器找到能提交财务数据的公司内部网Web点,再用鼠标器点击一下或两下,便可调这些数字。服务器将不仅快速给你数据,

3、而且给出显示它所需的销售分析小应用程序。这些数字在Java数据表中将浮现到你的屏幕上,因而你能即兴地使用它们,而不是麻烦地把它们调入你自己的数据表程序中。为用图形表示这些数字,你可以调入作图表的小应用程序,让你漂漂亮亮地打印出报表来,而所有这些不必离开浏览器。你也能得到最新最好的小应用于程序版本:因为这种软件只存储在一个地方,公司的技术人员可较容易地使其保持最新。然而,Java语言的真正优点是具有让用户省钱和省力,因为它大大简化了应用程序的开发与部署使用,而且让它们保留已有的传统计算机和软件。Java程序一旦写好了,就能在任何一种计算机(PC机、Macintosh机、Unix工作站甚至是大型机

4、)上无须修改就能运行。基本的操作系统是没有差别的。Java实际上给予了那些较旧的专用计算机(有变成废品风险的产品)新的生命。在不到一年的时间内,Java已成了微软的PC操作系统Windows系列的主要挑战者,比DOS和Windows挑战传统的大型机和小型机的速度还要快。Java也在成为最重要的Internet软件标准的道路上迅跑,使Sun超过Netscape和微软成为Internet计算的领袖需求分析是要完成的最重要的任务之一,因为它回答了以下问题。用户的问题有哪些?计算机有帮助吗?要求系统做什么?解决问题的预备工作有哪些?如果更进一步地研究 index.jsp 和 form1.jsp(这两个

5、 JSP 文件构成该应用程序),会发现另一个缺点:错误处理相当笨拙。错误处理代码是在 form1.jsp 中,其中我必须重复显示代码,并添加代码以插入用户在前一表单屏幕(index.jsp)中输入的值。如果用户概要信息域曾更改过,或者如果输入表单的显示曾更改过,就必须更新这两个地方中的代码。我可以将 form1.jsp 的错误处理部分与 index.jsp 中的初始表单显示结合在一起,但在初始表单装入时,我仍将需要做额外的工作以把域值设置成空字符串,并且我仍将需要有一个物理文件名来表示用户概要信息的最终静态显示,这意味着发生更改时,该应用程序结构仍是很脆弱的。Struts 表单自动化可以解决这

6、种笨拙的表单处理缺陷。现在,让我们研究刚才看到的 Web 应用程序示例中的 Struts 和 Tiles 版本。请执行下列步骤:转至 EX2_INSTALL 目录。 编辑 build.xml 文件,为 struts.install.dir 和 tomcat.install.dir 填写适当的值。 输入 ant deploy 。这将把第二个示例应用程序构建到 WAR 文件中以备部署,然后将它部署至 Tomcat。如果看到关于无法复制文件的错误,请检查第 2 步以确保正确设置了 struts.install.dir 和 tomcat.install.dir 。 将 Web 浏览器指向 http:/

7、localhost:8080/ex2。您应该会看到“Hello, World”页面。 如果您已看过 EX2_INSTALL 目录,您很可能会说:“这里要做些什么呢?有好多文件。”与大多数强调更有序和结构化程度更高的技术一样,对于 Struts 和 Tiles,在一开始需要在管理文件上花些工夫。对于只有少许页面的小项目,这一额外开销可能微不足道。然而,随着项目变大,Struts 和 Tiles 方法逐渐会显示其优越性。让我们一点点地体会吧!这里我不想讨论 EX2_INSTALL/src/WEB-INF/web.xml;尽管这个文件实质上与其示例 1 中相对应的文件不同,而且大多数行都是样板,但理

8、解这些设置对于着手开发并不太重要。在 EX2_INSTALL/src/WEB-INF/struts-config.xml 中,自先前有关 Struts 的文章以来重要的更改有在 节中 DynaActionForm 的使用及在 节中 tile 作为目标的使用。在 Struts 的以前版本中,您必须为每个所使用的表单 bean 定义一个 Java 类。仅当不同的 HTML 表单共享域时,才可以在这些表单之间共享表单 bean。总之,每个表单 bean 需要有一个 Java 类是一个非常麻烦的要求。现在,您可以在 struts-config.xml 文件中指定表单 bean 的特性,而且是 迅速地!

9、不必有保存 Java 类的单独文件,就能自动创建这种 bean。象处理 Hashtable 对象一样,用值的强类型对象来处理动态表单 bean。至于操作映射,一旦确定将 Tiles 库合并到 Struts 分发版之后,那么指定一个 tile 作为目标,就完全是增加一项逻辑而已。您会在概要信息表单的操作映射中看到 tile 目标(tile.profileInput 和 tile.profileOutput)。在 input 属性和 path 属性中指定 tile。注:可以指定 tile 目标弥补了我在分析以页面为中心的模型中提到的更改文件名和位置中的缺陷:tile 目标是虚拟名称或逻辑名称,而不

10、是物理名称。 在 标记中指定 tile。您可以将定义命名为任何希望的名称,而且 name 属性不必是与 path 属性匹配的子字符串。我为第一个定义选择了名称 rootLayout ,以表明它是应用程序中的页面要遵循的基本布局。注:路径是 /tiles-layout/rootLayout.jsp。如果查看 EX2_INSTALL/src/web 下的 /tiles-layout/rootLayout.jsp,您会看到这种布局是多么的简单整齐。用户界面的设计人员会“爱上它”。还请注意:它不包含任何代码,所以用户界面设计人员在进行更改时不必担心破坏什么。 rootLayout.jsp 中的 标记对

11、应于 tiles-defs.xml 中 rootLayout 定义内的 标记。注:每个 标记都有一个表示逻辑名称的属性。每个逻辑名称映射至通过在 tiles-defs.xml 内的 中使用 标记指定的名称和值。通过在 rootLayout.jsp 页面中使用逻辑名称,而非物理名称,并通过在 tiles-defs.xml 中统一物理名称,我们就可以更改文件名,并使项目文件系统的组织易于管理。 真正节省时间和适应性方面最显著的增强方面体现在布局的继承,这是 Struts 的另一个特性。在 tiles-defs.xml 中,“Page definitions”栏下面的节有两个页面:tile.prof

12、ileInput 和 tile.profileOutput。这些名称是任意的,如果您不喜欢 tile. 前缀,可以不使用它(但是您使用的名称必须与 struts-config.xml 文件中指定的目标相匹配)。这些名称应该与 struts-config.xml 中 标记中的 path 属性匹配。这些名称还应该与 struts-config.xml 中 标记中的 input 属性匹配。在开发用户界面时, 标记中的 extends 属性是体现开发灵活性的地方。通过指定主布局并扩展它,您不仅能灵活更改象 topBanner 、 topMenu 、 panel1 、 panel2 这样的公共元素及其它

13、组件, 还能随意地将不同元素放在页面上及更改它们的位置。例如,您可以添加 panel4 (一个 tile)以在页面左侧的 panel2 下显示本地天气。只要天气代码不需要用户的任何输入或与页面上的其它组件交互,您就可以添加 panel4 而不必对应用程序业务逻辑做任何更改,甚至不必更改除 rootLayout.jsp 以外的 JSP 页面。 篇幅所限,不允许我再深入讨论 Struts 和 Tiles 包其它一些实用的方面,但我真的想简要地谈一下,这样您可以对 Struts 和 Tiles 可以做些什么有所了解。如果有足够的需求,可能这些内容会是将来文章的主题。您会在本文的两个示例中注意到,我编

14、码了名、姓、喜欢的颜色和出生日期等基本验证。我所采用的这类简单验证实际上可由 Struts 通过使用它的格式验证来执行,这样节省了花在编码 Java 语句的时间。例如,检查是否是空字符串、检查字符串是否与日期相匹配或检查是否与其它某些正则表达式匹配等,这都是可行的。您会发现将格式验证用作第一级检查会是十分方便的,在检查是否符合更复杂的业务逻辑规则之前,程序可用第一级检查来消除一些明显错误。Struts 提供了一个验证器包,可以通过 WEB-INF 目录中的 validator.xml 描述符来配置该包。在这两个示例中我没有包含该验证器包;如果您想试一下,它包含在 Struts 1.1-b1 包

15、中。Struts 和 Tiles 包的另一个有用特性是与容器管理的安全性相集成。很多人都在使用诸如 IBM WebSphere 或 JBoss 之类的应用程序服务器。这些服务器通过处理安全性中所涉及的许多日常任务使认证和授权更便捷,让您摆脱必须对它们进行的编码。Struts 允许您根据用户角色有条件地向不同用户显示 bean 数据的不同位,这可以通过自动查询容器来决定。同样地,Tiles 框架允许您根据用户角色有条件地向不同用户显示不同的视图组件,这也是通过自动查询容器来决定的。我在自己的应用程序中使用这些特性向管理员、常规用户或 guest 用户显示不同的菜单。最后要说明,我在示例中没有谈到

16、国际化,但对于那些构建将来最终要以多种语言发布的大型应用程序的人来说,这实际是一个重要方面。Struts 让您创建消息资源特性文件,这些文件指定标签、标题和其它输出的文本。如果您用几种不同语言的输出填入消息资源特性文件的话,只要简单更改语言设置就能将所有窗口构件和硬编码的文本更改成适当语言,甚至在应用程序运行中也可以更改。Struts 和 Tiles 将走向何方呢?刚出现的两个更改必定会使 Struts 和 Tiles 更加有用。第一个更改是工作流管理系统。您很可能处理过许多多步骤的业务过程;目前,在 Web 应用程序中对它们进行编码可以是一个主要的麻烦,因为您必须协调不同的步骤,而每一步骤都

17、是 Java 类中的一个单独方法或是一个单独的 servlet 或 JSP 页面。商业市场中的工具通过使开发人员能对多步骤的业务过程进行建模,然后自动生成 Java 代码作为进一步开发的基础,来帮助管理这些过程。Struts 工作流管理系统将提供类似的功能,使开发人员能够编写业务过程的脚本,这些过程在 Web 应用程序中跨多个页面,并指定这些页面如何通过核心的基于规则的系统进行交互。另一个同样有望即将出现的更改是将 Struts 标记合并到 JSP 标准标记库(JSP Standard Tag Library)中,这个库是 Jakarta 项目,它试图产生一个有用的定制标记集合,从而简化并加快

18、用 JSP 页面编写 Web 应用程序的开发。其中的意义在于:Web 应用程序的开发将比过去任何时候都更容易,因为您可以通过使用定制标记的标准机制得到一个在此基础上做进一步开发的预先编写好的代码库。而且,JSP STL 标准中这个项目的合并甚至确保了 Struts 和 Tiles 功能更为广泛的分发和可用,这意味具有这种技能的开发人员在众多项目中大有作为,而且公司更加容易获得开发 Web 应用程序的熟练人才。附录B英文原文Java is one of the hyped-up Internet software technologies that have spawned the World

19、Wide Web, awful words like intranet, and those strange-looking addresses on business cards and TV commercials. Originally known as a way to jazz up Web pages with graphic animations - stock tickers that crawl across your screen, for example, and dancing icons - Java has quickly evolved into a whole

20、lot more. To Microsofts dismay, it is fast becoming what is known as a computing platform - a sturdy base upon which programmers can build software applications.Java is making possible the rapid development of versatile programs for communicating and collaborating on the Internet. Were not just talk

21、ing word processors and spreadsheets here, but also applications to handle sales, customer service, accounting, databases, and human resources - the meat and potatoes of corporate computing. Java is also making possible a controversial new class of cheap machines called network computers, or NCs, wh

22、ich Sun, IBM, Oracle, Apple, and others hope will proliferate in corporations and our homes. The way Java works is simple. Unlike ordinary software applications, which take up megabytes on the hard disk of your PC, Java applications, or applets, are little programs that reside on the network in cent

23、ralized servers. The network delivers them to your machine only when you need them; because the applets are so much smaller than conventional programs, they dont take forever to download. Say you want to check out the sales results from the Southwest region. Youll use your Internet browser to find t

24、he corporate intranet Website that dishes up financial data and, with a mouse click or two, ask for the numbers. The server will zap you not only the data, but also the sales-analysis applet you need to display it. The numbers will pop up on your screen in a Java spreadsheet, so you can noodle aroun

25、d with them immediately rather than hassle with importing them to your own spreadsheet program. To graph the numbers, youll call in a charting applet that will let you print out your report nice and pretty, all without leaving your browser. And youll always get the latest, greatest version of the ap

26、plets too: Since the software is stored in only one place, corporate technicians can keep it up to data more easily. The real beauty of the Java language, however, is its power to save users money, because it vastly simplifies creating and deploying applications and because it lets them keep their e

27、xisting legacy computers and software. Java programs, once written, can run without modification on just about any kind of computer: a PC, a Macintosh, a UNIX workstation - heck, even a mainframe. The underlying operating system makes no difference. Java actually can breathe new life into older spec

28、ialized computers that were at risk of becoming obsolete. In scarcely a year, Java has evolved into a major challenger to Microsofts Windows family of PC operating systems - faster even than DOS and Windows rose to challenge traditional mainframes and minicomputers. Java is also well on its way to b

29、ecoming the most important Internet software standard, catapulting Sun past Netscape and Microsoft as the leader in Internet computing. The requirements analysis is one of the most important tasks to undertake,because it answers such questions as: What is the users problem? Will a computer help? Wha

30、t is the system required to do? What are some preliminary approaches to the problem?If you look closely at index.jsp and form1.jsp, the two JSP files comprising the application, another drawback will be apparent: the error handling is quite awkward. The error handling code is in form1.jsp, where I m

31、ust repeat the display code and add code to insert the values the user entered in the previous form screen (index.jsp). If the user profile fields ever change, or if the display of the input form ever changes, I must update code in two places. I could combine the error handling portion of form1.jsp

32、with the initial form display in index.jsp, but I would still need to do extra work to set the field values to empty strings upon the initial form load, and I would still need to have a physical filename for the final static display of the user profile, which means that the application structure wou

33、ld remain fragile when change occurred. This drawback of awkward form handling is addressed by Struts form automation.Hello, World: New and improvedNow, lets look at the Struts and Tiles version of the example Web application we just saw. Perform the following steps:Change to the EX2_INSTALL directo

34、ry.Edit the build.xml file and fill in appropriate values for struts.install.dir and tomcat.install.dir.Type ant deploy. This will build the second example application into a WAR file ready for deployment, then deploy it to Tomcat. If you see an error about not being able to copy files, check to mak

35、e sure that the struts.install.dir and tomcat.install.dir properties were set appropriately in step 2.Point your Web browser to http:/localhost:8080/ex2. You should see a Hello, World page. Youre probably saying,Whats going on here? There are a lot more files. As with mosttechnologies that impose mo

36、re order and structure, with Struts and Tiles there is a startup cost in the form of administrative files. For a small project of a few pages, this additional overhead may not make sense. As the project grows, however, the Struts and Tiles approach really begins to shine. Lets take it piece by piece

37、. I wont cover EX2_INSTALL/src/WEB-INF/web.xml; although this file is substantially different from its Example 1 counterpart, most of the lines are boilerplate,and understanding the important changes since the earlier article on Struts are the use of DynaActionForm in the section and the use of tile

38、s as targets in the section. In previous versions of Struts, you had to define a Java class for every form bean that you used. You could share form beans between different HTML forms only if they shared fields. Overall, the requirement of a Java class for every formbean was a big pain. Now you can s

39、pecify the form beans propertiesin the struts-config.xml file, and presto! The bean is automatically created without need for a separate file housing a Java class. The dynamic form beans are treated like Hashtable objects with strongly typed objects for values. As for action mappings, the ability to

40、 specify a tile as a target was a completely logical addition once the decision was made to incorporate the Tiles library into the Struts distribution. You can see the tile targets (tile.profileInput and tile.profileOutput) in the action mapping for the profile form. The tiles are specified in the i

41、nput attribute and the path attribute. Note that the ability to specify a tile target remedies the problem of changing filenames and locations mentioned in my analysis of the page-centric model: tile targets are virtual or logical names rather than physical names.Tiles are specified in tags. You can

42、 name the definitions anything you want, and the name attribute does not have to be a substring match of the path attribute. I have chosen the name rootLayout for the first definition to indicate that it is the base layout that pages in the application will follow. Note the path: /tiles-layout/rootL

43、ayout.jsp. If you look at /tiles-layout/rootLayout.jsp under EX2_INSTALL/src/web, you will see how simple and clean the layout is. A user interface designer would love it. Note also that it contains no code, so the user interface designer can make changes without worrying about breaking anything.The

44、 tags in rootLayout.jsp correspond to the tags within the rootLayout definition in tiles-defs.xml. Note that the tags each have an attribute representing a logical name. Each logical name maps to a name and value specified using a tag in the tag within tiles-defs.xml. By using logical rather than ph

45、ysical names in the rootLayout.jsp page and by consolidating physical names in tiles-defs.xml, we make changes to filenames and project filesystem organization manageable.The real savings in time and the most significant increase in adaptability comes with inheritance of layouts, another Struts feat

46、ure. In tiles-defs.xml, the section below the Page definitions banner has two pages: tile.profileInput and tile.profileOutput. The names are arbitrary and you dont need the tile. prefix if you dont like it (though the name you use must match targets specified in the struts-config.xml file). The name

47、s should match the path attribute in the tags in struts-config.xml. The names should also match the input attribute in the tags in struts-config.xml. The extends attribute in the tag is where the magic that delivers agility to user interface development happens. By specifying a master layout and extending it, you have the flexibility of not only changing common elements like topBanner, topMenu, panel1, panel2, and other components, but also the freedom to put different elements on the page and change where they are located.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1