【正文】
Action 的 bean 屬性 . 最后 ,操作請求的 Action 實(shí)例在一個視圖里面獲得付值和 form population. 然而 ,參考數(shù)據(jù)也需要作為 Action 的屬性被模擬 . 一個類里面有太多的角色是值得討論的 . 關(guān) 于視圖 :Spring 的視圖方案非常的靈活 . 一個控制器執(zhí)行可以通過 response 返回 ModelAndView 對象 null,就可以直接寫到一個視圖 .在通常的狀況下 ,一個 ModelAndView 實(shí)例結(jié)合了 一個view 和一個 model Map,包含了 bean name 和 通訊對象 (像命令或者 form,參考數(shù)據(jù)等等 ). View 名稱是非常高端的的配置,不是通 過 bean name, 一個 properties 文件就是通過你自己的 model Map 允許你在視圖層面完成提 取 ,沒有任何的爭辯 JSP/Velocity 或者其他 ,每一種都可以直接完整使用 .這個 model Map 還可以簡單得得到適當(dāng)?shù)母袷交瘮?shù)據(jù)的轉(zhuǎn)換 ,像 JSP 請求屬性或者 Velocity 模版模式 . Hibernate應(yīng)用框架 數(shù)據(jù)持久層及 Hibernate Hibernate是一個數(shù)據(jù)持久層框架 , 是一種實(shí)現(xiàn)對象和關(guān)系之間映射 ( O/R Mapping) 的工具 , 它對 JDBC進(jìn)行了輕量級的對象封裝 ,使程序員可以使用對象編程思想來操作數(shù)據(jù)庫。它不僅提供了從 Java類到數(shù)據(jù)表的映射,也提供了數(shù)據(jù)查詢和恢復(fù)機(jī)制。相對 于使用 JDBC和 SQL來操作數(shù)據(jù)庫,使用 Hibernate能大大的提高實(shí)現(xiàn)的效率。 Hibernate框架用配置文件的形式來定義Java對象和數(shù)據(jù)表之間的映射關(guān)系,同時(shí)在更深的層面將數(shù)據(jù)表之間的關(guān)系解釋為 Java對象之間的繼承及包含等關(guān)系。通過使用 HQL語句將復(fù)雜的關(guān)系算法用對象的方式描述,在很大程度上簡化了對數(shù)據(jù)的查詢,加快了開發(fā)的效率。在Hibernate中有一個簡單而直觀的 API,用于對數(shù)據(jù)庫所表示的對象執(zhí)行查詢。要創(chuàng)建或修改這些對象,只需在程序中與它們進(jìn)行交互,然后告訴 Hibernate保存即 中原工學(xué)院信息商務(wù)學(xué)院畢業(yè)設(shè)計(jì)(論文)譯文專用紙 第 6頁 可。這樣 ,大量封裝持久化操作的業(yè)務(wù)邏輯不再需要編寫煩瑣的 JDBC語句,從而使數(shù)據(jù)持久層得到了極大的簡化。 運(yùn)用 Hibernate和 Struts開發(fā) J2EE應(yīng)用 以在 J2EE應(yīng)用中非常普遍的用戶登錄過程為例,來說明上述體系結(jié)構(gòu)是如何具體運(yùn)用的。登錄的流程非常清晰:用戶從登錄頁面 ,系統(tǒng)對登錄信息進(jìn)行驗(yàn)證,如果正確則成功登錄,否則提示相應(yīng)錯誤信息。 在開發(fā)過程中,使用 Eclipse做為開發(fā)環(huán)境,同時(shí)加載了對 Struts及 Hibernate提供更好的控制和支持的第三方插件 MyEclipse, Web服務(wù)器使用 Tomcat,數(shù)據(jù)庫選用了 Mysql。 首先對 Hibernate進(jìn)行配置,只需要對系統(tǒng)自動生成的 進(jìn)行修改,配置好數(shù)據(jù)庫連接的各種參數(shù)以及定義數(shù)據(jù)映射文件。由于 Hibernate所帶的連接池主要用于測試,性能不是很好,可以通過 JNDI將其修改為使用Tomcat的連接池。 小結(jié) 在本文中,我們介紹了 Struts 應(yīng)用框架。并介紹了一些基本知識,關(guān)于 Spring,以及 Hibernate。我們也說明了如何運(yùn)用 Hibernate 和 Struts 開發(fā) J2EE,以及 它如何用來將 servlets 和 JSP 在結(jié)合在同一個應(yīng)用之中?,F(xiàn)在你已經(jīng)有關(guān)于 Strtus Web應(yīng)用程序模樣的初步印象,以后我們將更深入的討論 Strtuts 框架的理論和具體實(shí)踐。 中原工學(xué)院信息商務(wù)學(xué)院畢業(yè)設(shè)計(jì)(論文)譯文專用紙 第 7頁 原文出處: SSH based on Web Technology Introduction 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 .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 , also appeared some problem in the tradition J2 the EE the application of the development the process: 1)the antinomy of of data model and logic model. Currently the database of usage basically and all is relation type database, 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 maintenance。 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 the EJB container carry on development and adjust to try to need to be waste a great deal of lowering the Ou of code to match sex, exaltation system of development efficiency, this text put forward 1 kind EE according to the J2 of the Struts frame and Spring frame and the Hibernate frame application development strategy. Use the Struts realization MVC structure use the Struts realization MVC structure MVC(ModelViewController) is put forward by the Trygve Reenskaug, first drive application in the environment SmallTalk80, is many to hand over with each other with interface system of constitute 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 processing problem logic at 中原工學(xué)院信息商務(wù)學(xué)院畢業(yè)設(shè)計(jì)(論文)譯文專用紙 第 8頁 independence in outside manifestation under contents and form circumstance of inside abstract, packed the core data, logic of problem and function of calculation relation, independence in concrete of interface expression and I/O operation. See diagram(View) mean information and particular form demonstration of m