【正文】
使程序員可以使用對象編程思想來操作數(shù)據(jù)庫。但是,在傳統(tǒng) J2EE應(yīng)用的開發(fā)過程中也出現(xiàn)了一些問題: (1)數(shù)據(jù)模型和邏輯模型之間的 矛盾。在 Hibernate中有一個簡單而直觀的 API,用于對數(shù)據(jù)庫所表示的對象執(zhí)行查詢??刂破鳎?Controller)是處理用戶與軟件的交互操作的,其職責是控制提供模型中任何變化的傳播,確保用戶界面于模型間的對 應(yīng)聯(lián)系;它接受用戶的輸入,將輸入反饋給模型,進而實現(xiàn)對模型的計算控制,是使模型和視圖協(xié)調(diào)工作的部件。在 Struts中,承擔 MVC中控制器角色的是 ActionServlet。模型以一個或多個 Java Bean的形式存在。 例如 : 一個校驗應(yīng)用將不用依靠 controllers 就可以實現(xiàn)。 這個框架的的設(shè)計思想是在你的應(yīng)用需要改良的時候,你將會做一些技術(shù)的選擇 , 例如 ,如果你需要分布式事務(wù)處理,你可能需要用 Spring 的 Jta TransactionManager 來實現(xiàn) JTA 服務(wù) 。 舉例來說 ,它描述了具有在應(yīng)用范圍內(nèi)的校驗錯誤的輸入機制 ,但不是系統(tǒng)錯誤 , 所以在你的 form 對象里面你不必復(fù)制你的業(yè)務(wù)對象 的 spring 屬性 ,只操作出錯的子任務(wù) ,或者適當?shù)剞D(zhuǎn)換spring。 關(guān)于視圖 :Spring 的視圖方案非常的靈活 。 可訂制的 綁 定和數(shù)據(jù)校驗作為應(yīng)用級的輸入機制的錯誤校驗 ,固定日期和數(shù)字 綁 定 ,例如 ,通過手動檢查和轉(zhuǎn)換業(yè)務(wù)對象來替換單個的 string。 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 one kind EE according to the J2 of the Struts frame 、 the Hibernate frame and the Spring frame application development strategy. The Hibernate Frame Data39。s web support or 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, your business logic will not unnecessarily depend on container services like JTA or EJB allowing plex, wellarchitected web applications to run in a simple container like Tomcat or that Spring doesn39。s data binding is highly flexible, . it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. So you don39。t any plugins involved, therefore no dedicated integration: From the view of the web layer, you39。s unique features are: .Clear separation of roles: controller vs validator vs mand object vs form object vs model object, DispatcherServlet vs handler mapping vs view resolver, etc. .Powerful and straightforward configuration of both framework and application classes as JavaBeans, including easy inbetween referencing via an application context, . from web controllers to business objects and validators. .Adaptability, nonintrusiveness: Use whatever Controller subclass you need (plain, mand, form, wizard, multi action, or a custom one) for a given scenario instead of deriving from Action/ActionForm for everything. .Reusable business code, no need for duplication: You can use existing business objects as mand or form objects instead of mirroring them in special ActionForm subclasses. .Customizable binding and validation: type mismatches as applicationlevel validation errors that keep the offending value, localized date and number binding, etc instead of Stringonly form objects with manual parsing and conversion to business objects. Customizable handler mapping, customizable view resolution: flexible model transfer via name/value Map, handler mapping and view resolution strategies from simple to sophisticated instead of one single way. With in the J2 the EE the application very widespread customer register process for example, elucidation abovementioned system structure is how concrete usage. The process of register is very clear: Customer from register page importation register information, system to register the information carry on verification, if exactitude success register, otherwise hint correspond mistake information. In the development process, the usage Eclipse be used as development environment and added to carry to provide to the Struts and the Hibernate in the meantime better control and support of three square plugin MyEclipse, Web server usage Tomcat, the database chose to use Mysql. Carry on an allocation to the Hibernate first, need to the system auto the born . xml carry on modification, allocation good database conjunction of various parameter and definition the data reflect to shoot a document. Because the Hibernate take of conjunction pond main used for test, the function isn39。s web MVC 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 access it via its