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

下載本文檔

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

文檔簡(jiǎn)介

1、<p>  Web MVC with the Spring Framework</p><p>  Juergen Hoeller</p><p>  1.      Introduction: Spring the Application Framework </p><p>  When first c

2、onfronted with the Spring Framework, one might be tempted to think: "Oh no, not yet another web framework". This article will outline why Spring isn't particularly a web framework but a generic lightweight

3、application framework with dedicated web support, and show the architectural differences to Struts and WebWork</p><p>  In contrast to Struts or WebWork, Spring is an application framework for all layers: It

4、 offers a bean configuration foundation, AOP support, a JDBC abstraction framework, abstract transaction support, etc. It is a very non-intrusive effort: Your application classes do not need to depend on any Spring class

5、es if not necessary, and you can reuse every part on its own if you like to. From its very design, the framework encourages clean separation of tiers, most importantly web tier and business log</p><p>  Of c

6、ourse, Spring's own web support is nicely integrated with the framework's general patterns. Nevertheless, replacing the web solution with Struts, WebWork, or the like is easy. Both with Spring's web support o

7、r a different one, Spring allows for building a true dedicated middle tier in the web container, with the option to reuse exactly the same business logic in test environments or standalone applications. And within J2EE,

8、your business logic will not unnecessarily depend on container servi</p><p>  Note that Spring doesn't generally aim to compete with existing solutions. It rather fosters seamless integration with standa

9、rds like Servlet, JSP, JTA, JNDI, JDBC, and JDO, and well-suited tools like Hibernate, Velocity, Log4J, and Caucho's Hessian/Burlap. The framework is designed to grow with the needs of your applications, in terms of

10、technology choice: For example, you will probably use JTA via Spring's JtaTransactionManager if you need distributed transactions - but only then, as there are</p><p>  2.      W

11、eb MVC: The Design of Spring's Web Framework </p><p>  Spring's web framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view res

12、olution, and locale and theme resolution. The default handler is a very simple Controller interface, just offering a "ModelAndView handleRequest(request,response)" method. This can already be used for applicati

13、on controllers, but you will prefer the included implementation hierarchy, consisting of AbstractController, AbstractCommandController, MultiActio</p><p>  You can take any object as command or form object:

14、There's no need to implement an interface or derive from a base class. Spring's data binding is highly flexible, e.g. it treats type mismatches as validation errors that can be evaluated by the application, not a

15、s system errors. So you don't need to duplicate your business objects' properties as Strings in your form objects, just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it

16、9;s often preferable to bind </p><p>  Regarding views: Spring's view resolution is extremely flexible. A Controller implementation can even write a view directly to the response, returning null as Model

17、AndView. In the normal case, a ModelAndView instance consists of a view name and a model Map, containing bean names and corresponding objects (like a command or form, reference data, etc). View name resolution is highly

18、configurable, either via bean names, via a properties file, or via your own ViewResolver implementation. The abstrac</p><p>  3.      Integration: Using a Different Web Framework wit

19、h Spring </p><p>  Many teams will try to leverage their investments in terms of know-how and tools, both for existing projects and for new ones. Concretely, there are not only a large number of books and to

20、ols for Struts but also a lot of developers that have experience with it. Thus, if you can live with Struts' architectural flaws, it can still be a viable choice for the web layer. The same applies to WebWork and oth

21、er web frameworks.</p><p>  If you don't want to use Spring's web MVC but intend to leverage other solutions that Spring offers, you can integrate the web framework of your choice with Spring easily.

22、 Simply start up a Spring root application context via its ContextLoaderListener, and access it via its ServletContext attribute (or Spring's respective helper method) from within a Struts or WebWork action. Note tha

23、t there aren't any "plugins" involved, therefore no dedicated integration: From the view of the web layer, you'll</p><p>  4.      Feature Check List </p>&l

24、t;p>  If just focussing on the web support, some of Spring's unique features are: .Clear separation of roles: controller vs validator vs command object vs form object vs model object, DispatcherServlet vs handler

25、mapping vs view resolver, etc. .Powerful and straightforward configuration of both framework and application classes as JavaBeans, including easy in-between referencing via an application context, e.g. from web controlle

26、rs to business objects and validators. .Adaptability, non-intrusiveness: </p><p><b>  翻譯文稿</b></p><p>  Spring的web MVC 構(gòu)架模式</p><p>  Juergen Hoeller</p><p>

27、  1.   介紹:Spring 應(yīng)用構(gòu)架 </p><p>  當(dāng)你第一次看到Spring的時(shí)候,你一定會(huì)說:"哦不,又一種web 構(gòu)架".這篇文章將告訴你Spring明顯區(qū)別于其他輕量級(jí)application framework, 它將專注于web的支持,與struts 和 webwork有著明顯的區(qū)別。 </p><p>  在和struts

28、和 webwork的對(duì)比上,Spring是一個(gè)服務(wù)于所有層面的application framework:提供了bean的配置基礎(chǔ),AOP的支持,JDBC的提取框架,抽象事務(wù)支持,等等。它有一個(gè)非常顯著的特點(diǎn):在某個(gè)層面上如果你不需要Spring的支持,你就可以不使用String的class,只使用它的某一部分的功能。 從它的設(shè)計(jì)理念,你可以看到String 幫助你實(shí)現(xiàn)了真正的邏輯層和web層的分離:例如。一個(gè)校驗(yàn)應(yīng)用將不用依靠cont

29、rollers,就可以實(shí)現(xiàn)。這樣的目標(biāo)是 更好的重用和易測(cè):過分依靠不必要的容器和框架將不能實(shí)現(xiàn)這一點(diǎn)。</p><p>  當(dāng)然,Spring 的自己的web支持和通??蚣苣J降募?xì)致完整.然而,Spring替換struts,webwork或者其他的web方案非常的容易.對(duì)于Spring的web支持或者不同的地方,Spring 允許你在web容器里面建立一個(gè)中間層,在測(cè)試環(huán)境或者標(biāo)準(zhǔn)獨(dú)立的應(yīng)用里面來設(shè)置重用你的商

30、務(wù)邏輯.還有在J2EE環(huán)境里面,你的商務(wù)邏輯不必依靠容器提供的服務(wù),像JTA ,EJB的支持.良好的構(gòu)架的web應(yīng)用可以運(yùn)行在任何容器上,如,Tomcat 或者 Resin. 值得注意的是,Spring 不是和已經(jīng)存在的解決方案進(jìn)行競(jìng)爭(zhēng). 我們鼓勵(lì)結(jié)合標(biāo)準(zhǔn)的技術(shù),如, Servlet, JSP, JTA, JNDI, JDBC, and JDO, 和非常匹配的工具,如,Hibernate, Velocity, Log4J, and Ca

31、ucho's Hessian/Burlap.這個(gè)框架的的設(shè)計(jì)思想是在你的應(yīng)用需要改良的時(shí)候,你將會(huì)做一些技術(shù)的選擇:例如,如果你需要分布式事務(wù)處理,你可能需要用Spring的Jta TransactionManager 來實(shí)現(xiàn)JTA服務(wù).或者,用DataSourceTr</p><p>  2.   Web MVC:Spring web 框架的設(shè)計(jì)思想</p><p

32、>  Spring 框架通過配置操作mappings,展示resolution,本地化和模版集成圍繞著分派請(qǐng)求操作的servlet - DispatcherServlet設(shè)計(jì)的.缺省的操作是一個(gè)非常簡(jiǎn)單的控制接口, 他只提供了ModelAndView handleRequest(request,response)方法.這將用于一個(gè)應(yīng)用的控制,但是,如果你想包含多個(gè)層次的控制,AbstractController, Abstract

33、CommandController, MultiActionController, SimpleFormController, AbstractWizardFormController 將幫助你完成.應(yīng)用控制將代表那些子系統(tǒng).注意,你可以選擇一個(gè)適當(dāng)?shù)幕?如果你沒有 web form,你就不必用FormController.這就是和Struts最大的不同. 你可以通過命令或者form對(duì)象來操作任何對(duì)象:這不需要接口工具或者一個(gè)基礎(chǔ)類的

34、驅(qū)動(dòng).Spring的數(shù)據(jù)邦定是非常的靈活的.舉例來說,它描述了具有在應(yīng)用范圍內(nèi)的校驗(yàn)錯(cuò)誤的輸入機(jī)制,但不是系統(tǒng)錯(cuò)誤.所以在你的for</p><p>  3.   集成:用Spring一個(gè)不同web 框架 </p><p>  許多開發(fā)團(tuán)隊(duì)將為他們已有的項(xiàng)目或者新的項(xiàng)目已經(jīng)獲得的期限和工具進(jìn)行投資.這里沒有像Struts那樣大量的圖書和工具,但是同樣我們有大量的擁有Sp

35、ring開發(fā)技巧的開發(fā)人員.然而,如果你愿意生活在Struts的構(gòu)架瑕疵中的話,他將是你在web層開發(fā)不錯(cuò)的選擇.當(dāng)然,其他應(yīng)用也是一樣. 如果你不想用Spring的 web MVC ,但是想借用Spring嫁接其他的解決方案,你可以非常簡(jiǎn)單地通過Spring 繼承你自己的web 框架.你可以非常簡(jiǎn)單地通過ContextLoaderListener 啟動(dòng)一個(gè)Spring root application context, 并且,通過St

36、ruts 或者WebWork 的action 利用ServletContext 屬性(或者Spring 的helper方法)存取它. 值得注意的是, 這里沒有任何的 "plugins"被調(diào)用,因此沒有專門的集成:來自web層的視圖, 你可以簡(jiǎn)單的將Spring作為一個(gè)管理application context 實(shí)例入口點(diǎn)的類庫. 所有你注冊(cè)bean和Spring服務(wù)都可以在不需要Spring的web MVC的情況&l

37、t;/p><p><b>  4.特點(diǎn)核對(duì)列表</b></p><p>  如果聚焦于web 支持,Spring的一些顯著特點(diǎn)是: 清楚地角色分離:controller , validator , command object , form object , model object,和 DispatcherServlet , handler mapping vs vie

38、w resolver, 等等 強(qiáng)大而且直接的框架和作為JavaBeans的應(yīng)用配置,包括簡(jiǎn)單的參照和應(yīng)用內(nèi)容,例如,從web控制器到業(yè)務(wù)對(duì)象和數(shù)據(jù)校驗(yàn). 適應(yīng)性,外掛:無論什么樣的控制器你都需要得到代替Action/ActionForm所做的每件事情的方案(簡(jiǎn)單,命令,form,范例,多重action,或者定制一個(gè)) 重用業(yè)務(wù)邏輯代碼,不需要復(fù)制:你可以用已經(jīng)有的業(yè)務(wù)邏輯對(duì)象作為命令或則form對(duì)象代替反射特定的ActionForm子類

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論