2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩14頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、<p><b>  翻譯文稿1、</b></p><p>  Spring的web MVC 構(gòu)架模式</p><p>  Juergen Hoeller</p><p>  1.介紹:Spring 應(yīng)用構(gòu)架 </p><p>  當(dāng)你第一次看到Spring的時候,你一定會說:"哦不,又一種web 構(gòu)架

2、".這篇文章將告訴你Spring明顯區(qū)別于其他輕量級application framework, 它將專注于web的支持,與struts 和 webwork有著明顯的區(qū)別。 </p><p>  在和struts 和 webwork的對比上,Spring是一個服務(wù)于所有層面的application framework:提供了bean的配置基礎(chǔ),AOP的支持,JDBC的提取框架,抽象事務(wù)支持,等等。它有一

3、個非常顯著的特點(diǎn):在某個層面上如果你不需要Spring的支持,你就可以不使用String的class,只使用它的某一部分的功能。 從它的設(shè)計(jì)理念,你可以看到String 幫助你實(shí)現(xiàn)了真正的邏輯層和web層的分離:例如。一個校驗(yàn)應(yīng)用將不用依靠controllers,就可以實(shí)現(xiàn)。這樣的目標(biāo)是 更好的重用和易測:過分依靠不必要的容器和框架將不能實(shí)現(xiàn)這一點(diǎn)。</p><p>  當(dāng)然,Spring 的自己的web支持和通

4、??蚣苣J降募?xì)致完整.然而,Spring替換struts,webwork或者其他的web方案非常的容易.對于Spring的web支持或者不同的地方,Spring 允許你在web容器里面建立一個中間層,在測試環(huán)境或者標(biāo)準(zhǔn)獨(dú)立的應(yīng)用里面來設(shè)置重用你的商務(wù)邏輯.還有在J2EE環(huán)境里面,你的商務(wù)邏輯不必依靠容器提供的服務(wù),像JTA ,EJB的支持.良好的構(gòu)架的web應(yīng)用可以運(yùn)行在任何容器上,如,Tomcat 或者 Resin. 值得注意的是,S

5、pring 不是和已經(jīng)存在的解決方案進(jìn)行競爭. 我們鼓勵結(jié)合標(biāo)準(zhǔn)的技術(shù),如, Servlet, JSP, JTA, JNDI, JDBC, and JDO, 和非常匹配的工具,如,Hibernate, Velocity, Log4J, and Caucho's Hessian/Burlap.這個框架的的設(shè)計(jì)思想是在你的應(yīng)用需要改良的時候,你將會做一些技術(shù)的選擇:例如,如果你需要分布式事務(wù)處理,你可能需要用Spring的Jta T

6、ransactionManager 來實(shí)現(xiàn)JTA服務(wù).或者,用DataSourceTr</p><p>  2. Web MVC:Spring web 框架的設(shè)計(jì)思想</p><p>  Spring 框架通過配置操作mappings,展示resolution,本地化和模版集成圍繞著分派請求操作的servlet - DispatcherServlet設(shè)計(jì)的.缺省的操作是一個非常簡單的控制接

7、口, 他只提供了ModelAndView handleRequest(request,response)方法.這將用于一個應(yīng)用的控制,但是,如果你想包含多個層次的控制,AbstractController, AbstractCommandController, MultiActionController, SimpleFormController, AbstractWizardFormController 將幫助你完成.應(yīng)用控制將代表那

8、些子系統(tǒng).注意,你可以選擇一個適當(dāng)?shù)幕?如果你沒有 web form,你就不必用FormController.這就是和Struts最大的不同. 你可以通過命令或者form對象來操作任何對象:這不需要接口工具或者一個基礎(chǔ)類的驅(qū)動.Spring的數(shù)據(jù)邦定是非常的靈活的.舉例來說,它描述了具有在應(yīng)用范圍內(nèi)的校驗(yàn)錯誤的輸入機(jī)制,但不是系統(tǒng)錯誤.所以在你的for</p><p>  3.集成:用Spring一個不同web

9、 框架 </p><p>  許多開發(fā)團(tuán)隊(duì)將為他們已有的項(xiàng)目或者新的項(xiàng)目已經(jīng)獲得的期限和工具進(jìn)行投資.這里沒有像Struts那樣大量的圖書和工具,但是同樣我們有大量的擁有Spring開發(fā)技巧的開發(fā)人員.然而,如果你愿意生活在Struts的構(gòu)架瑕疵中的話,他將是你在web層開發(fā)不錯的選擇.當(dāng)然,其他應(yīng)用也是一樣. 如果你不想用Spring的 web MVC ,但是想借用Spring嫁接其他的解決方案,你可以非常簡單

10、地通過Spring 繼承你自己的web 框架.你可以非常簡單地通過ContextLoaderListener 啟動一個Spring root application context, 并且,通過Struts 或者WebWork 的action 利用ServletContext 屬性(或者Spring 的helper方法)存取它. 值得注意的是, 這里沒有任何的 "plugins"被調(diào)用,因此沒有專門的集成:來自web

11、層的視圖, 你可以簡單的將Spring作為一個管理application context 實(shí)例入口點(diǎn)的類庫. 所有你注冊bean和Spring服務(wù)都可以在不需要Spring的web MVC的情況</p><p><b>  4.特點(diǎn)核對列表</b></p><p>  如果聚焦于web 支持,Spring的一些顯著特點(diǎn)是: 清楚地角色分離:controller , v

12、alidator , command object , form object , model object,和 DispatcherServlet , handler mapping vs view resolver, 等等 強(qiáng)大而且直接的框架和作為JavaBeans的應(yīng)用配置,包括簡單的參照和應(yīng)用內(nèi)容,例如,從web控制器到業(yè)務(wù)對象和數(shù)據(jù)校驗(yàn). 適應(yīng)性,外掛:無論什么樣的控制器你都需要得到代替Action/ActionForm所做的

13、每件事情的方案(簡單,命令,form,范例,多重action,或者定制一個) 重用業(yè)務(wù)邏輯代碼,不需要復(fù)制:你可以用已經(jīng)有的業(yè)務(wù)邏輯對象作為命令或則form對象代替反射特定的ActionForm子類. 可訂制的邦定和數(shù)據(jù)校驗(yàn):作為應(yīng)用級的輸入機(jī)制的錯誤校驗(yàn),固定日期和數(shù)字邦定,例如,通過手動檢查和轉(zhuǎn)換業(yè)務(wù)對象來替換單個的string。 可訂制的操作,可訂制的視圖方案:通過name/value Map靈活的模型傳送,用一個簡單的方法從簡單

14、到復(fù)雜操作映射和視圖</p><p>  本地定制和主題方案:Spring沒有taglib,完全支持于JSPs,JSTL,不需要額外的連接就可以支持Velocity,等等. 簡單但是強(qiáng)大的tag library避免了HTML產(chǎn)生的混亂,最大限度的靈活擴(kuò)展了標(biāo)記代碼. </p><p><b>  翻譯文稿2、</b></p><p>  一種基

15、于Hibernate和Struts的J2EE應(yīng)用開發(fā)策略</p><p>  本文分析了Hibernate和Struts的機(jī)制,提出了一種基于Hibernate和Struts的J2EE應(yīng)用開發(fā)策略。在這種策略中,模型層用Hibernate實(shí)現(xiàn),視圖和控制器則用Struts框架實(shí)現(xiàn)。這樣可大大降低代碼的耦合性以及提高系統(tǒng)的開發(fā)效率。</p><p>  關(guān)鍵字 Hibernate,Strut

16、s,MVC,持久層 </p><p><b>  1 引言 </b></p><p>  隨著Java技術(shù)的逐漸成熟與完善,作為建立企業(yè)級應(yīng)用的標(biāo)準(zhǔn)平臺,J2EE平臺得到了長足的發(fā)展。借助于J2EE規(guī)范中包含的多項(xiàng)技術(shù):Enterprise JavaBean(EJB)、Java Servlets(Servlet)、Java Server Pages(JSP)、Java

17、 Message Service(JMS)等,開發(fā)出了許多應(yīng)用系統(tǒng)。但是,在傳統(tǒng)J2EE應(yīng)用的開發(fā)過程中也出現(xiàn)了一些問題:</p><p>  1)數(shù)據(jù)模型和邏輯模型之間的矛盾。目前使用的數(shù)據(jù)庫基本上都是關(guān)系型數(shù)據(jù)庫,而Java本質(zhì)上是一種面向?qū)ο蟮恼Z言,對象在存儲和讀取時使用SQL和JDBC進(jìn)行數(shù)據(jù)庫操作,降低了編程的效率以及系統(tǒng)的可維護(hù)性;</p><p>  2)傳統(tǒng)的J2EE應(yīng)用多

18、采用基于EJB的重量級框架,這種框架適合于開發(fā)大型企業(yè)應(yīng)用,但是使用EJB容器進(jìn)行開發(fā)和調(diào)試需要耗費(fèi)大量時間。為了降低代碼的耦合性,提高系統(tǒng)的開發(fā)效率,本文提出了一種基于Struts框架和Hibernate框架的J2EE應(yīng)用開發(fā)策略。 </p><p>  2 數(shù)據(jù)持久層及Hibernate Hibernate是一個數(shù)據(jù)持久層框架,是一種實(shí)現(xiàn)對象和關(guān)系之間映射(O/R Mapping)的工具,它對JDBC進(jìn)行了輕

19、量級的對象封裝,使程序員可以使用對象編程思想來操作數(shù)據(jù)庫。它不僅提供了從Java類到數(shù)據(jù)表的映射,也提供了數(shù)據(jù)查詢和恢復(fù)機(jī)制。相對于使用JDBC和SQL來操作數(shù)據(jù)庫,使用Hibernate能大大的提高實(shí)現(xiàn)的效率。Hibernate框架用配置文件的形式來定義Java對象和數(shù)據(jù)表之間的映射關(guān)系,同時在更深的層面將數(shù)據(jù)表之間的關(guān)系解釋為Java對象之間的繼承及包含等關(guān)系。通過使用HQL語句將復(fù)雜的關(guān)系算法用對象的方式描述,在很大程度上簡化了對

20、數(shù)據(jù)的查詢,加快了開發(fā)的效率。在Hibernate中有一個簡單而直觀的API,用于對數(shù)據(jù)庫所表示的對象執(zhí)行查詢。要創(chuàng)建或修改這些對象,只需在程序中與它們進(jìn)行交互,然后告訴Hibernate保存即可。這樣,大量封裝持久化操作的業(yè)務(wù)邏輯不再需要編寫煩瑣的JDBC語句,從而使數(shù)據(jù)持久層得到了極大的簡化。 </p><p>  3 用Struts實(shí)現(xiàn)MVC架構(gòu) MVC(Model-View-Controller)由Try

21、gve Reenskaug提出,首先被應(yīng)用在SmallTalk-80環(huán)境中,是許多交互和界面系統(tǒng)的構(gòu)成基礎(chǔ)。根據(jù)界面設(shè)計(jì)可變性的需求,MVC把交互系統(tǒng)的組成分解成模型、視圖、控制器三部分。 模型(Model)是軟件所處理問題邏輯在獨(dú)立于外在顯示內(nèi)容和形式情況下的內(nèi)在抽象,封裝了問題的核心數(shù)據(jù)、邏輯和功能的計(jì)算關(guān)系,獨(dú)立于具體的界面表達(dá)和I/O操作。視圖(View)把表示模型數(shù)據(jù)及邏輯關(guān)系和狀態(tài)的信息及特定形式展示給用戶。它從模型獲得顯示

22、信息,對于相同的信息可以有多個不同的顯示形式或視圖??刂破鳎–ontroller)是處理用戶與軟件的交互操作的,其職責(zé)是控制提供模型中任何變化的傳播,確保用戶界面于模型間的對應(yīng)聯(lián)系;它接受用戶的輸入,將輸入反饋給模型,進(jìn)而實(shí)現(xiàn)對模型的計(jì)算控制,是使模型和視圖協(xié)調(diào)工作的部件。通常一個視圖對應(yīng)一個控制器。模型、視圖與控制器的分離,使得一個模型可以具有多個顯示視圖。如果用戶通過某個視圖的控制器改變了模型的數(shù)據(jù),所有其它依賴于這些數(shù)據(jù)的視圖都應(yīng)

23、反映到這些變化。因此,無論</p><p>  Struts框架最早是作為Apache Jakarta項(xiàng)目的組成部分問世運(yùn)做,它繼承了MVC的各項(xiàng)特性,并根據(jù)J2EE的特點(diǎn),做了相應(yīng)的變化與擴(kuò)展。Struts框架很好的結(jié)合了Jsp,Java Servlet,Java Bean,Taglib等技術(shù)。在Struts中,承擔(dān)MVC中控制器角色的是ActionServlet。ActionServlet是一個通用的控制組件

24、。這個控制組件提供了處理所有發(fā)送到Struts的HTTP請求的入口點(diǎn)。它截取和 分發(fā)這些請求到相應(yīng)的動作類(這些動作類都是Action類的子類)。另外控制組件也負(fù)責(zé)用相應(yīng)的請求參數(shù)填充Action Form(FromBean),并傳給動作類(ActionBean)。動作類訪問核心商業(yè)邏輯,即訪問Java Bean或調(diào)用EJB。最后動作類把控制權(quán)傳給后續(xù)的JSP文件,由JSP文件生成視圖。所有這些控制邏輯利用Struts-config.x

25、ml文件來配置。在Struts框架中,視圖主要由JSP生成頁面完成,Struts提供豐富的JSP標(biāo)簽庫,這有利于分開表現(xiàn)邏輯和程序邏輯。模型以一個或多個Java Bean的形式存在。在Stru</p><p>  4 運(yùn)用Hibernate和Struts開發(fā)J2EE應(yīng)用 </p><p>  以在J2EE應(yīng)用中非常普遍的用戶登錄過程為例,來說明上述體系結(jié)構(gòu)是如何具體運(yùn)用的。登錄的流程非常清

26、晰:用戶從登錄頁面login.jsp輸入登錄信息,系統(tǒng)對登錄信息進(jìn)行驗(yàn)證,如果正確則成功登錄,否則提示相應(yīng)錯誤信息。 在開發(fā)過程中,使用Eclipse做為開發(fā)環(huán)境,同時加載了對Struts及Hibernate提供更好的控制和支持的第三方插件MyEclipse,Web服務(wù)器使用Tomcat,數(shù)據(jù)庫選用了Mysql。 首先對Hibernate進(jìn)行配置,只需要對系統(tǒng)自動生成的hibernate.cfg.xml進(jìn)行修改,配置好數(shù)據(jù)庫連接的各種參

27、數(shù)以及定義數(shù)據(jù)映射文件。由于Hibernate所帶的連接池主要用于測試,性能不是很好,可以通過JNDI將其修改為使用Tomcat的連接池。</p><p><b>  原文1(復(fù)印稿)</b></p><p>  Web MVC with the Spring Framework</p><p>  Juergen Hoeller</p&

28、gt;<p>  1.      Introduction: Spring the Application Framework </p><p>  When first confronted with the Spring Framework, one might be tempted to think: "Oh no, not yet

29、another web framework". This article will outline why Spring isn't particularly a web framework but a generic lightweight application framework with dedicated web support, and show the architectural differences

30、to Struts and WebWork</p><p>  In contrast to Struts or WebWork, Spring is an application framework for all layers: It offers a bean configuration foundation, AOP support, a JDBC abstraction framework, abstr

31、act transaction support, etc. It is a very non-intrusive effort: Your application classes do not need to depend on any Spring classes if not necessary, and you can reuse every part on its own if you like to. From its ver

32、y design, the framework encourages clean separation of tiers, most importantly web tier and business log</p><p>  Of course, Spring's own web support is nicely integrated with the framework's general

33、 patterns. Nevertheless, replacing the web solution with Struts, WebWork, or the like is easy. Both with Spring's web support or a different one, Spring allows for building a true dedicated middle tier in the web con

34、tainer, with the option to reuse exactly the same business logic in test environments or standalone applications. And within J2EE, your business logic will not unnecessarily depend on container servi</p><p>

35、  Note that Spring doesn't generally aim to compete with existing solutions. It rather fosters seamless integration with standards like Servlet, JSP, JTA, JNDI, JDBC, and JDO, and well-suited tools like Hibernate, Ve

36、locity, Log4J, and Caucho's Hessian/Burlap. The framework is designed to grow with the needs of your applications, in terms of technology choice: For example, you will probably use JTA via Spring's JtaTransaction

37、Manager if you need distributed transactions - but only then, as there are</p><p>  2.      Web MVC: The Design of Spring's Web Framework </p><p>  Spring's web

38、framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, and locale and theme resolution. The default handler is a very simple Controller

39、 interface, just offering a "ModelAndView handleRequest(request,response)" method. This can already be used for application controllers, but you will prefer the included implementation hierarchy, consisting of

40、AbstractController, AbstractCommandController, MultiActio</p><p>  You can take any object as command or form object: There's no need to implement an interface or derive from a base class. Spring's d

41、ata binding is highly flexible, e.g. it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. So you don't need to duplicate your business objects' properties

42、 as Strings in your form objects, just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it's often preferable to bind </p><p>  Regarding views: Spring's view re

43、solution is extremely flexible. A Controller implementation can even write a view directly to the response, returning null as ModelAndView. In the normal case, a ModelAndView instance consists of a view name and a model

44、Map, containing bean names and corresponding objects (like a command or form, reference data, etc). View name resolution is highly configurable, either via bean names, via a properties file, or via your own ViewResolver

45、implementation. The abstrac</p><p>  3.      Integration: Using a Different Web Framework with Spring </p><p>  Many teams will try to leverage their investments in term

46、s of know-how and tools, both for existing projects and for new ones. Concretely, there are not only a large number of books and tools for Struts but also a lot of developers that have experience with it. Thus, if you ca

47、n live with Struts' architectural flaws, it can still be a viable choice for the web layer. The same applies to WebWork and other web frameworks.</p><p>  If you don't want to use Spring's web MV

48、C but intend to leverage other solutions that Spring offers, you can integrate the web framework of your choice with Spring easily. Simply start up a Spring root application context via its ContextLoaderListener, and acc

49、ess it via its ServletContext attribute (or Spring's respective helper method) from within a Struts or WebWork action. Note that there aren't any "plugins" involved, therefore no dedicated integration:

50、From the view of the web layer, you'll</p><p>  4.      Feature Check List </p><p>  If just focussing on the web support, some of Spring's unique features are:

51、.Clear separation of roles: controller vs validator vs command object vs form object vs model object, DispatcherServlet vs handler mapping vs view resolver, etc. .Powerful and straightforward configuration of both framew

52、ork and application classes as JavaBeans, including easy in-between referencing via an application context, e.g. from web controllers to business objects and validators. .Adaptability, non-intrusiveness: </p><

53、p><b>  原文2(復(fù)印稿)</b></p><p>  A Development Strategy Application Based on the Hibernate and the Struts J2EE </p><p>  This text analysis the mechanism of Hibernate and Struts, put

54、forward 1 kind EE according to the J2 of the Hibernate and the Struts application development strategy.In this kind of strategy, the model layer use a Hibernate realization and see diagram and controller to then use a St

55、ruts frame a realization.So can consumedly lower the development efficiency that the Ou of code match sex and exaltation system. </p><p>  The key word : Hibernate, Struts, the MVC, hold out for long time<

56、;/p><p>  1.One preface along with the Java technique of gradual mature and perfect, Be establishment business enterprise class application of standard terrace, the J2 EE terrace got substantial of development

57、.Several technique asked for help from to include in the J2 EE norm : Enterprise JavaBean (EJB), Java Servlets (Servlet), Java Server Pages(JSP), Java Message Service(JMS)...etc., development many application system.But,

58、 also appeared some problem in the tradition J2 the EE the application of the de</p><p>  1)the antinomy of of data model and logic model. Currently the database of usage basically and all is relation type d

59、atabase, but the Java be essentially a kind of the language which face to object, object at saving with read usage SQL and JDBC carry on a database operation and lowered plait distance of efficiency and system of can mai

60、ntenance;</p><p>  2)tradition of J2 EE application much the adoption is according to the EJB heavy weight frame, this kind of frame suitable for develop a large business enterprise application, but usage th

61、e EJB container carry on development and adjust to try to need to be waste a great deal of time.For lowering the Ou of code to match sex, exaltation system of development efficiency, this text put forward 1 kind EE accor

62、ding to the J2 of the Struts frame and the Hibernate frame application development strategy.</p><p>  2 Data's holding out for long time layer and Hibernate is one piece according to hold out for long ti

63、me layer frame, is a kind of realization object and relation of the tool which reflect to shoot(O/R Mapping), it carried on the object of the lightweight to pack to the JDBC and make procedure member can usage object pla

64、it distance thought to operation database. It not only provided to shoot from Java to reflect of data form, but also provided a data a search and instauration mechanism. Opposite </p><p>  3 use the Struts r

65、ealization MVC structure MVC(Model-View-Controller) is put forward by the Trygve Reenskaug, first drive application in the environment SmallTalk-80, is many to hand over with each other with interface system of constitut

66、e foundation. According to the need of variable of the interface design, MVC hand over with each other constitute of system to resolve into model and see diagram, controller three part. Model(Model) is software processin

67、g problem logic at independence in outside</p><p>  The Struts frame is to be the item of Apache Jakarta to constitute part to publish luck to do at the earliest stage, it inherited MVC of each item characte

68、ristic, and did according to the characteristics of J2 EE correspond of variety with expand. The Struts frame was good to combine Jsp , Java Servlet , Java Bean, Talia etc. technique. In the Struts, what to undertake the

69、 controller role in the MVC be an ActionServlet. The ActionServlet is an in general use control module. This control module p</p><p>  4.2 Development practice underneath combine a development practice, with

70、 in the J2 the EE the application very widespread customer register process for example, elucidation above-mentioned system structure is how concrete usage. The process of register is very clear: Customer from register p

71、age login.jsp importation register information, system to register the information carry on verification, if exactitude success register, otherwise hint correspond mistake information. In the development proc</p>

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論