




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、畢業(yè)設(shè)計(jì)(論文)外文文獻(xiàn)翻譯院系:計(jì)算機(jī)與信息工程學(xué)院年級(jí)專業(yè):姓名:學(xué)號(hào):附件:Spring Web Mvc Framework for Rapid OpenSource J2EE Application Development指導(dǎo)老師評(píng)語(yǔ)指導(dǎo)教師簽名:年月日運(yùn)用spring mvc框架進(jìn)行快速的開(kāi)源 J2EE應(yīng)用程序開(kāi)發(fā):案例研究摘要一當(dāng)今,web應(yīng)用程序的開(kāi)發(fā)競(jìng)爭(zhēng)非常激烈,時(shí)代要求開(kāi)發(fā)出的應(yīng)用程序 非常準(zhǔn)確、經(jīng)濟(jì)和高效。人們致力于開(kāi)發(fā)出能提高生產(chǎn)效率和降低復(fù)雜性的應(yīng)用程 序,轉(zhuǎn)變程序員開(kāi)發(fā)java2平臺(tái)企業(yè)版的web應(yīng)用程序的方法已經(jīng)成為一個(gè)基本的 運(yùn)動(dòng)。本文中我們討論的重點(diǎn)是怎樣開(kāi)發(fā)出
2、 j2ee 兼容的軟件而無(wú)需使用企業(yè) java bean(EJB)。最好的選擇之一就是運(yùn)用spring框架,spring框架提供了許多服務(wù), 但是相比于EJB,它的侵入性大大降低了。這種轉(zhuǎn)變背后的驅(qū)動(dòng)力是 web應(yīng)用程序 開(kāi)發(fā)和實(shí)施領(lǐng)域提高生產(chǎn)率和降低復(fù)雜性的需要。 本文中,我們將簡(jiǎn)要介紹 spring 的基本體系結(jié)構(gòu)并且給出一個(gè)運(yùn)用了 spring mvc 框架的案例研究實(shí)例。關(guān)鍵詞 :mvc, spring , xmlI、簡(jiǎn)介現(xiàn)今,網(wǎng)絡(luò)問(wèn)題是非常復(fù)雜的。由于公司和組織的需求都在不斷的增加,應(yīng)用 程序開(kāi)發(fā)的復(fù)雜性和系統(tǒng)性能是需要解決的主要問(wèn)題。不同類型的通訊設(shè)備的復(fù)雜 性在不斷增加,而業(yè)務(wù)要
3、求應(yīng)用程序使用網(wǎng)絡(luò)和許多通訊設(shè)備,并且互聯(lián)網(wǎng)上數(shù)據(jù) 負(fù)載不斷的增加,這些迫使我們不得不考慮起應(yīng)用程序的體系架構(gòu)問(wèn)題?,F(xiàn)在,讓 我們討論在保持應(yīng)用程序模型視圖結(jié)構(gòu)不變的情況下,spring web mvc快速應(yīng)用程序開(kāi)發(fā)框架是如何快速工作的。Spring 框架具有豐富的功能集,我們將簡(jiǎn)要討論這些功能。1. 控制反轉(zhuǎn):控制反轉(zhuǎn),即IOC。它是有線服務(wù)或者將組件添加到應(yīng)用程序所 使用的技術(shù)之一。IOC是“一種軟件設(shè)計(jì)模式和相關(guān)的編程技術(shù)集”,與傳統(tǒng)的交互 模式相比,運(yùn)用IOC后,系統(tǒng)的控制流是反向的。在IOC容器內(nèi)不是應(yīng)用程序調(diào)用 框架而是框架調(diào)用應(yīng)用程序指定的組件。IOC可以被解釋為“把運(yùn)行時(shí)所需
4、要的資 源或者依賴注入到相關(guān)的資源中去” ,這也被稱為依賴注入。是 spring IOC 容器的 實(shí)際表現(xiàn),它是負(fù)責(zé)控制和管理 bean 的。 BeanFactory 接口是 spring IOC 容器的 主要接口。Bean就是由spring IOC容器實(shí)例化和管理的對(duì)象。這些 bean和他們之 間的依賴關(guān)系反應(yīng)在容器所使用的配置元數(shù)據(jù)中。2. 構(gòu)造函數(shù)依賴注入:我們可以使用 java 類的構(gòu)造函數(shù)來(lái)加載 bean 的值。首 先定義一個(gè)只有單一構(gòu)造函數(shù)的類,然后使用 details.xml 文件提供構(gòu)造函數(shù)所需 要的值,最后用一個(gè)實(shí)現(xiàn)了 beanfactory 接口方法的類來(lái)加載 xml 文件
5、。這是使用 xml 文件把值加載到 java 文件的構(gòu)造函數(shù)中,這種方法適用于向構(gòu)造函數(shù)傳遞值。3.Setter 依賴注入:給每一個(gè) bean 定義其 get 和 set 方法。我們可以利用 set 方法在設(shè)定bean中的值。Set方法會(huì)覆蓋掉從bean中加載的值。4. 接口:我們可以在 spring 中定義接口類。為了實(shí)現(xiàn)這一點(diǎn),必須為 java 程 序?qū)虢涌?,然后我們可以利用接口中定義的方法來(lái)使用 spring 和 xml 文件。5. 繼承:一個(gè) java 類可以獲得另一個(gè) java 類的屬性,就像只有一個(gè) java 程序一樣。繼承有三種子類型: 1)抽象型: spring 中定義成抽象
6、類的 bean 只能被繼 承。2)父子型:定義的的繼承層次結(jié)構(gòu)想父子關(guān)系一樣。3)父-子-孫子型:這種類型的繼承關(guān)系可以定義 3個(gè)或者更多的類層次結(jié)構(gòu)。6. 自動(dòng)裝配:自動(dòng)裝配用于將 xml 文件中屬性的鍵和值映射到 java 文件中去。 有4種裝配的類型:byName(通過(guò)名字)、byType (通過(guò)類型)、constructor (通 過(guò)構(gòu)造函數(shù))、 autodetect (自動(dòng)檢測(cè))。如果沒(méi)有定義裝配的類型,那么默認(rèn)是以 通過(guò)名字的方式來(lái)裝配的。7. Bean的作用域:spring中定義的所有bean有四種類型的作用域,即session, request , singleton , gl
7、obal-session 。這些是用來(lái)控制 bean 的訪問(wèn)范圍的。8. 引用bean:在xml文件中的一個(gè)bean可以從其他的bean分配值。這嘗嘗用 于從一個(gè)bean中讀取值然后再分配給另一個(gè) bean。n> spring 的主要組件Spring框架依然遵循mvc的思想原則。它是為桌面應(yīng)用和基于互聯(lián)網(wǎng)的應(yīng)用而 設(shè)計(jì)的。 Spring 由三個(gè)相互協(xié)作的核心組件組成。 1、控制器:處理業(yè)務(wù)邏輯中的 跳轉(zhuǎn)邏輯和同服務(wù)層的交互。2、模型:控制器和視圖之間的橋梁,包含著控制器給予視圖所需要的數(shù)據(jù)。 3、視圖:呈現(xiàn)請(qǐng)求后的響應(yīng), 從模型中提取數(shù)據(jù)。 Spring 的核心組件如下所示:1. Dis
8、patcherServlet :它是 spring 的前端控制器的實(shí)現(xiàn)。 Web.xml 接收請(qǐng)求 并且把它轉(zhuǎn)移到 DispatcherServlet , DispatcherServlet 是與請(qǐng)求進(jìn)行交互的第 一個(gè)控制器,它也被稱為 Servlet 的執(zhí)行。它控制著應(yīng)用程序的完整流和跳轉(zhuǎn)流。2. 控制器:這個(gè)是使用者為了處理請(qǐng)求而創(chuàng)建的組件,它封裝了跳轉(zhuǎn)邏輯???制器將服務(wù)委托給服務(wù)對(duì)象。3. 視圖:視圖是負(fù)責(zé)渲染呈現(xiàn)輸出的。在輸出的結(jié)果集、顯示設(shè)備和通訊設(shè)備 的基礎(chǔ)上,不同類型的輸出要選擇不同的視圖。4.ModelAndView: ModelAndView是spring框架的核心部分。它
9、實(shí)現(xiàn)了應(yīng)用程 序的業(yè)務(wù)邏輯,由控制器創(chuàng)建。它使視圖和請(qǐng)求聯(lián)系起來(lái)并且存儲(chǔ)了業(yè)務(wù)邏輯和模 型數(shù)據(jù)。當(dāng)一個(gè)控制器調(diào)用它的時(shí)候,它才會(huì)執(zhí)行。在執(zhí)行時(shí),它將返回視圖的數(shù) 據(jù)和名字。5.ViewResolver :輸出是如何顯示的取決于從 ModelAndView 中接收的結(jié)果。 ViewResolver 是將邏輯視圖名映射到實(shí)際視圖的實(shí)現(xiàn)。 這部分將確定和實(shí)現(xiàn)輸出的 是什么媒體以及如何去顯示它。6.HandlerMapping :它是 DispatcherServlet 將傳入的請(qǐng)求映射到單個(gè)控制器 時(shí)所使用的戰(zhàn)略性接口。它識(shí)別請(qǐng)求并且調(diào)用相應(yīng)的處理程序來(lái)提供服務(wù),處理程 序會(huì)調(diào)用控制器。川、spri
10、ng 的體系結(jié)構(gòu)Spring框架為開(kāi)發(fā)web應(yīng)用程序提供了功能全面的 mvc模型。Spring具有可 插撥的mvc架構(gòu),他可以配置多種視圖技術(shù),例如:jsp、velocity、tiles、iText 等等。Spring mvc分離了控制器,模型對(duì)象,分派器和處理對(duì)象的角色。對(duì)象和控 制器的清楚分離,使他們更容易進(jìn)行定制。圖 01顯示了執(zhí)行流程。圖 01下面的圖 02 顯示了 spring 模型的序列圖。圖中 dispatcher Servlet 是應(yīng)用 程序的入口點(diǎn),一旦 dispatcher Servlet 獲取請(qǐng)求服務(wù),它就會(huì)決定處理程序。 所有的處理程序和 servlet 都是相互映射的
11、。處理程序開(kāi)始運(yùn)行和調(diào)用相應(yīng)的控制 器,并且將請(qǐng)求的參數(shù)傳遞給控制器,這個(gè)時(shí)候控制器開(kāi)始工作,它包含了業(yè)務(wù)邏 輯,同時(shí)ModelAndView與控制器關(guān)聯(lián)起來(lái),在執(zhí)行時(shí),控制器會(huì)把ModelAndView返回給 dispatcher Servlet ,這個(gè)時(shí)候的 ModelAndView 包含了數(shù)據(jù) 和視圖名。 Dispatcher Servlet從控制器從獲得 ModelAndView,然后Servlet 會(huì)調(diào)用相應(yīng)的視圖解析器。視圖解析器會(huì)識(shí)別出視圖的名稱并且通過(guò)視圖名來(lái)提取相應(yīng)的數(shù)據(jù), 最后,它會(huì)以適當(dāng)?shù)母袷较蛴脩舫尸F(xiàn)各自的數(shù)據(jù)。圖 02spring 框架中應(yīng)用程序的流程IV> s
12、pring 和 xmlXml廣泛使用在spring框架中,它簡(jiǎn)化了開(kāi)發(fā)流程,節(jié)約了時(shí)間。Xml用于存儲(chǔ)在應(yīng)用程序執(zhí)行時(shí)所需要的一些數(shù)據(jù)。Web.xml 文件是應(yīng)用程序的入口點(diǎn),它會(huì)告訴你進(jìn)一步的跳轉(zhuǎn)路徑。它負(fù)責(zé)加載應(yīng)用程序上下文并且指定了負(fù)責(zé)調(diào)度 servlet 的 xml 文件名web.xml:-<?xml version="1.0" encoding="UTF-8"?><listener><listener-Class> </listener-Class></listener><ser
13、vlet><servlet-name>dispatcher</servlet-name><servletclass></servlet-class><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>dispatcher</servlet-name> <url-pattern>/send/*</url-pattern></servlet-m
14、apping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>以上就是xml文件,xml將與傳入到服務(wù)器的請(qǐng)求經(jīng)行交互。xml文件中明確 了要調(diào)度的 servlet 的名稱,應(yīng)用程序上下文和 index.jsp 作為歡迎頁(yè)面。 url 的 類型定義為 *.* ,這意味著它將會(huì)接受任意類型的傳入請(qǐng)求。Applicati onCon text.xml Applicati onCon text建立在 Bea n
15、F actory 之上,它使AOP特征、消息資源處理和事件傳播更容易集成在一起。BeanFactory提供了框架的配置和基本的功能, ApplicationContext 則大大提高了應(yīng)用的性能。當(dāng)在 j2EE 的環(huán)境下開(kāi)發(fā)應(yīng)用程序, ApplicationContext 是必不可少的。<?xml version="1.0" encoding="UTF-8"?><bean id="superClass" class="packagename.SuperClass" /><bean id
16、 ="subClass" class=" packagename.SubClass"></bean><property name="superClass" ref="superClass"/></beans>上述文件將加載 superclass.java (超類)的 bean 和 superclass.java 本身, 同時(shí)它還定義了參考類。Dispatcher-servlet.xml- spring 的 web mvc框架是一個(gè)以請(qǐng)求為驅(qū)動(dòng)的 web mvc框架,它是圍繞
17、一個(gè)servlet設(shè)計(jì)的,該servlet將請(qǐng)求轉(zhuǎn)發(fā)給控制器并且為 處理應(yīng)用程序提供了大量的功能。 DispatcherServlet 與 spring 的應(yīng)用程序上下文 完全集成在一起并且允許你使用 spring 的功能,它是應(yīng)用程序運(yùn)作的中央控制單 元。DispatcherServlet 定義了視圖解析器、bean類以及他們的在應(yīng)用程序中的映 射。<?xml version="1.0" encoding="UTF-8"?><beans xmlns=- ResourceViewResolver"><propert
18、y name="prefix"><value>/WEB-INF/views/</value></property><property name="suffix"><value>.jsp</value></property></bean><bean id="urlMapping" SimpleUrlHandlerMapping"><property name="mappings">&
19、lt;props><prop key ="/*">dispatchController</prop></props></property></bean><beanid="dispatchController"class="packagename.DispatchController"></bean></beans>V、spring是如何快速運(yùn)作的快速應(yīng)用程序開(kāi)發(fā)一直以來(lái)是行業(yè)的要求。目前有很多開(kāi)發(fā)工具來(lái)幫助快速應(yīng) 用程序開(kāi)發(fā),但是隨著
20、技術(shù)和需求的持續(xù)增加,能夠解決開(kāi)發(fā)規(guī)模不斷擴(kuò)大的應(yīng)用 程序的工具和架構(gòu)是急需的。工具不同于架構(gòu),spring是mvc架構(gòu)中的一種架構(gòu),它可以支持規(guī)模較大的應(yīng)用程序。這種技術(shù)和架構(gòu)一旦實(shí)現(xiàn),它很容繼承其它的應(yīng) 用程序而不觸及現(xiàn)有的代碼。 Spring 使用 xml 文件來(lái)幫助我們添加新的映射、 請(qǐng)求、 java bean 等等到應(yīng)用程序中去。W、架構(gòu)的優(yōu)點(diǎn)讓我們看看 spring mvc 架構(gòu)可以為一個(gè)項(xiàng)目帶來(lái)哪些架構(gòu)上的好處1.spring 可以有效的組織程序的中間層對(duì)象,而 EJB 則不會(huì)影響它。 Spring 的配置管理服務(wù)可以運(yùn)用在任何架構(gòu)層和任何運(yùn)行時(shí)環(huán)境中。2. spri ng we
21、b mvc框架是一個(gè)強(qiáng)大的,靈活的,精心設(shè)計(jì)的應(yīng)用程序框架,用 于使用mvc設(shè)計(jì)模式快速的開(kāi)發(fā)web應(yīng)用程序。3. spring 消除了單例模式的擴(kuò)散, 這是一個(gè)主要的問(wèn)題, 它減少了程序的可測(cè) 試性和面向?qū)ο笮浴?. 清晰的角色劃分:spring mvc很好的將組成web框架的各個(gè)組件所扮演的角 色劃分開(kāi)。所有的組件,例如控制器、命令對(duì)象、設(shè)置器等,每個(gè)組件都扮演著獨(dú) 特的角色。5. 適配控制器:如果你的應(yīng)用程序不需要一個(gè) html 表單,你可以寫(xiě)一個(gè)簡(jiǎn)單 的版本的 spring 控制器,該控制器不需要表單控制所需要的的所有額外的組件。 Spring 提供了幾種類型的控制器,每一種控制器用于
22、不同的用途。6.Spring 不再需要使用各種自定義屬性文件格式, 在整個(gè)應(yīng)用程序和項(xiàng)目中配 置操作始終是一致的。7.Spring 提供了良好的編程習(xí)慣來(lái)降低編程接口的成本,而不是類的成本。8. 用spring構(gòu)建的應(yīng)用程序盡可能少的依賴于它的API,在spring的應(yīng)用程序中大多數(shù)的業(yè)務(wù)對(duì)象都沒(méi)有依賴于 spring 。9. 使用了 spring 構(gòu)建的應(yīng)用程序是非常容易進(jìn)行單元測(cè)試的。lO.Spring可以使用EJB來(lái)實(shí)現(xiàn)選擇,而不是決定應(yīng)用程序的架構(gòu)。11.你可以選擇POJC或者本地EJB實(shí)現(xiàn)業(yè)務(wù)接口,而不影響代碼的調(diào)用。12.Spring提供了 EJB的一個(gè)替代品,這種適合很多應(yīng)用程序
23、。它可以在不使 用EJB容器的情況下使用ACP提供聲明式事務(wù)管理。13. 無(wú)論是使用JDBC或者h(yuǎn)ibernate的0/R映射時(shí),spring提供了一致的數(shù)據(jù) 訪問(wèn)框架。 同時(shí), 它也提供了一致的和簡(jiǎn)單的編程模型, 例如 JDBC,JMS,JavaMail,JNDI 和許多的 api, 這些使得 spring 是一個(gè)理想的架構(gòu)。14. 它是使用POJC創(chuàng)建應(yīng)用程序的框架,同時(shí)它也掩蓋了開(kāi)發(fā)程序的復(fù)雜性。15. 當(dāng)在使用JDBC時(shí),spring解決了連接泄露的問(wèn)題,我們只需要編寫(xiě)必要的 SQL它也解決了數(shù)據(jù)庫(kù)返回錯(cuò)誤的問(wèn)題。叫、總結(jié)Spring web mvc框架是一個(gè)在快速應(yīng)用程序開(kāi)發(fā)的環(huán)境下
24、為應(yīng)用程序提供環(huán)境 的框架。在此框架下,我們可以信賴應(yīng)用程序的一致性,性能和穩(wěn)定性。由于這是 一個(gè)開(kāi)放源碼的環(huán)境,所以建議開(kāi)發(fā)者繼續(xù)使用這種技術(shù)用于大尺寸的web應(yīng)用程 序環(huán)境。Spring Web MVC Framework for rapid open source J2EEapplication development: a case studyPraveen GuptaResearch Scholar, Singhania UniversityPacheri Bari, Rajasthan, IndiaProf. M.C. GovilGovt. Mahila Engineering C
25、ollegeAjmer, Rajasthan, IndiaAbstract Today it is the highly competitive for the development of Web application, it is the need of the time to develop the application accurately, economically, and efficiently. We are interested to increase productivity and decrease complexity. This has been an under
26、lying theme in a movementto change the way programmers approach developing Java 2 Platform, Enterprise Edition (J2EE) Web applications. Our focus is how to create J2EE-compliant software without using Enterprise Java Beans (EJB). The one of the best alternative is the Spring framework, which provide
27、s less services but it is much less intrusive than EJB. The driving force behind this shift is the need for greater productivity and reduced complexity in the area of Web application software developmentand implementation. In thispaper, webriefly describe spring underlying architecture and present a
28、 case study using Spring web MVC Framework. Index Terma: MVC, Spring, XMLI. INTRODUCTIONWeb is the very complex issues these days. Since the desire of the companies and organizations are increasing so the complexity and the performance of the web programming matters. Complexity with the different ty
29、pes of communication devices is increasing. The business is demanding applications using the web and many communication devices. So with the increase load of the data on the internet we have to take care of the architecture issue. Let us discuss how it works fast using spring web mvc framework the r
30、apid application development while maintaining the Model View Architecture of the application.Spring frameworks comes with rich set of features, let us discuss these features in brief.1. Inversion Of Control: Inversion of Control or IoC is one of the techniques used to wire services or components to
31、 an application program. The IoC is “ A software design pattern and set of associated programming techniques in which the flow of control of a system is inverted in comparison to the traditional interaction mode. ” In IoC instead of an application calling the framework, it is the framework that call
32、s the components specified by the application. The IoC can be explained as "Injection of required resources or dependency at run-time into the dependent resource" representation of the Spring IoC container which is responsible for containing and managing the beans. The BeanFactory interfac
33、e is the central IoC container interface in Spring. A bean is simply an object that is instantiated and managed by a Spring IoC container. These beans and the dependencies between them are reflected in the configuration metadata used by a container.2. Constructor Dependency Injection: we can use the
34、 java class constructor to load the bean values. A java Class is defined with a constructor of single field. Details.xml file provides the value to be passes to the constructor. Nowanother java loads the xml file using the BeanFactory Method. This uses the xml file to load values in the constructor
35、of the java file. This is used to pass values to the constructor.3. Setter Dependency Injection: With every bean we defined the getters and setters. We can also use setters method to set the values in the beans. setters method overrides the values loaded from the beans.4. Interface: we can define th
36、e interface class in spring. To implement this we will import interface to the java program. Nowwe can use methods defined in interface using spring and xml.5. Inheritance: One java class can acquired the properties of another class just like a java program. There are three sub types of it. 1. Abstr
37、act: Beans declared abstract cannot be inherited in the springs. 2. Parent Child: we can define hierarchy like parent child. 3. Parent- Child - Sub ChildRelationship: in this we can define hierarchy for 3 or more classes.6. Autowiring: Autowiring is used to map the property name, values in xml file
38、with java file. There are four types to integrate it. byName, byType, constructor, autodetect. If nothing is defined about it then byName is the default.7. Scope of Beans: All beans defined in spring are having scope of four values prototype, session, request, singleton,global-session. This is used
39、to control the access of the beans.8. Reference Beans: One bean in the xml file can be assigned values from the other bean. This is used to read values from one bean and assign to another bean.II. MAJOR SPRING COMPONENTSIn the spring we also follow the principals of the MVC. It has been designed mor
40、e for the desktop and internet based applications. Spring consist of three core collaborating components. 1. Controller: Handles navigation logic and interacts with the Service tier for business logic2. Model: The contract between the Controller and the View Contains the data needed to render the Vi
41、ew Populated by the Controller 3. View: Renders the response to the request Pulls data from the model. Core components in the spring MVC are as follows.1. DispatcherServlet: this is the spring ' s front controller implementation. Web.xml receives the request and transfer it to the DispatchServle
42、t. This is the first controller which interacts to the requests. It is also known as implementation of the Servlet. It controls the complete flow of the application and navigates the flow of application.2. Controller: this is the user created component for handling requests. It encapsulates the navi
43、gation logic with it. Controller delegates the services for the service object.3. View: view is responsible for rendering output. Different views can be selected for the different types of output bases on the results and the viewing device, communication devices.4. ModelAndView: ModelAndView is the
44、core part of the spring framework. It implements the business logic of the application. It is created by thecontroller. It associates the view to the request. It stores the business logic and Model data. A controller calls it and it will execute. Onexecution it will return the data and name of view.
45、5. ViewResolver: How the output is to be displayed depends on the result received from ModelAndView. It is used to map logical view names to actual view implementations. This part identifies and implement what is the output media and how to display it.6. HandlerMapping: Strategy interface used by Di
46、spatcherServlet for mapping incoming requests to individual Controllers. It identifies the requestandcalls the respective handler to provide the services. Handler will call to controller.III. SPRING ARCHITECTUREThe Spring framework provides a full-featured MVC module for building Web applications. w
47、ith spring 's pluggable MVC architecture. It is configurable with multiple view technologies Ex Java Server Pages, Velocity, Tiles, iText etc. Spring MVC separates the roles of the controller, model object, dispatcher Servlet and the handler object. Clear separation of objects and controllers ma
48、kes them easier to customize. The figure 01 shows the view of the execution flow.Figure 01The following figure 02 shows the sequence diagram of the spring model. In this the dispatcher Servlet is the entry point for the application. As soon the Dispatch Servlet get the request for the services and i
49、t will decides the handler.All handlers are mapped with the Servlet. Handler will come in action and will call the respective controller and the pass the request parameters to it.Now controller comes in action, it contains business logic and a ModelAndView is associated with the controller. On execu
50、tion it will return the ModelAndView to the Dispatch Servlet. This ModelAndView contains the data and view name.Dispatcher Servlet gets the ModelAndView from the controller. It contains the data and view name. Servlet will call the view resolver. View resolver will identify the name of the view thro
51、ugh whichdata is to be presented. Finally it will present the data to the respective and appropriate format to the user.Figure 2 :the sequence diagram of the spring modelIV. SPRING AND XMLXml is widely used in the spring framework. It simplify the development process and saves time. xml is used to s
52、tore the data, which is used during the execution of application.web.xml is the entry point in the application. It will tell you the further path of navigation. It loads the application context class and the tells the name of the dispatcher Servlet xml file. web.xml:- <?xml version="1.0"
53、; encoding="UTF-8"?> <servlet> <servlet-name>dispatcher</servlet-name><servletclass> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/send/*</url-p
54、attern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>The above web.xml .xml will interact with the incoming request on the server. This file defines the name of the Servlet which is dispatcher, App
55、licationContext and the index.jsp as welcome page. url pattern defined as *.* means it will all types of incoming request.ApplicationContext.xml:- The ApplicationContext is build on top of the BeanFactory. It provides an easy integration with Springs AOP features, message resource handling, event pr
56、opagation. The BeanFactory provides the configuration framework and basic functionality. ApplicationContext adds enhanced capabilities to application.While building applications in a J2EE-environment ApplicationContext must be used.<?xml version="1.0" encoding="UTF-8"?><
57、bean id="superClass" class="packagename.SuperClass" /> <bean id ="subClass" class=" packagename.SubClass"> </bean><property name="superClass" ref="superClass"/> </beans>The above file loads the bean of the SuperCl
58、ass.java and SubClass.java. It also defines the reference class.Dispatcher-servlet.xml:-Spring's web MVC framework is a request driven web MVC framework, it is designed around a servlet that dispatches requests to controllers and provides much functionality for handling the applications. Dispatc
59、herServlet is completely integrated with the Spring ApplicationContext and allows you to use feature of springs. Dispatcher Servlet is the central controlling unit for the working of the application. It is used to define the view resolver, beans, handlers and their mapping of the application.<?xm
60、l version="1.0" encoding="UTF-8"?><beans xmlns= <bean<property name="prefix"> <value>/WEB-INF/views/</value></property> <property name="suffix"><value>.jsp</value></property> </bean><property na
61、me="mappings"> <props><prop key ="/*">dispatchController</prop> </props></property></bean><bean id="dispatchController" class=" packagename.DispatchController"></bean></beans>V. HOW IT WORKS RAPIDRapid Application Development isthe requirement of the industry sincea long time. There are many development tools which have helped it. But gradually technology and the requirements goes on increasing so e need the tools and th
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO 19152-4:2025 EN Geographic information - Land Administration Domain Model (LADM) - Part 4: Valuation information
- 2025至2030中國(guó)白三烯a4水解酶行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢(shì)及投資規(guī)劃深度研究報(bào)告
- 2025至2030中國(guó)畜產(chǎn)品行業(yè)市場(chǎng)占有率及投資前景評(píng)估規(guī)劃報(bào)告
- 2025至2030中國(guó)瑜伽磚行業(yè)市場(chǎng)占有率及投資前景評(píng)估規(guī)劃報(bào)告
- 2025至2030中國(guó)玉米面筋粉(CGM)行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢(shì)及投資規(guī)劃深度研究報(bào)告
- 2025至2030中國(guó)牽引帶式裝載機(jī)行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢(shì)及投資規(guī)劃深度研究報(bào)告
- 學(xué)生自信心培養(yǎng)與行為表現(xiàn)的關(guān)系
- 管理人員能力提升培訓(xùn)
- 教育機(jī)器人如何改變課堂?教學(xué)助手視角
- 探索在線教育在醫(yī)療領(lǐng)域的發(fā)展趨勢(shì)與前景
- 共同借款人合同借條3篇
- 節(jié)約集約建設(shè)用地標(biāo)準(zhǔn) DG-TJ08-2422-2023
- 手術(shù)室物品清點(diǎn)原則與制度
- 藥品批發(fā)企業(yè)現(xiàn)代物流基本要求DB41-T 2318-2022
- GB/T 625-2024化學(xué)試劑硫酸
- 采血針市場(chǎng)發(fā)展前景分析及供需格局研究預(yù)測(cè)報(bào)告
- 氣胸完整版本
- 重慶市智慧園林綠化管理信息系統(tǒng)-可行性研究報(bào)告(國(guó)信咨詢)
- 2023-2024學(xué)年山東省泰安市泰山區(qū)七年級(jí)(下)期末數(shù)學(xué)試卷(五四學(xué)制)(含答案)
- 2024住院患者靜脈血栓栓塞癥預(yù)防護(hù)理與管理專家共識(shí)要點(diǎn)(全文)
- 2024車輛掛靠證明
評(píng)論
0/150
提交評(píng)論