【正文】
s web MVC. Spring doesn39。s often preferable to bind directly to your business objects. This is another major difference to Struts which is built around required base classes like Action and ActionForm for every type of action. Compared to WebWork, Spring has more differentiated object roles: It supports the notion of a Controller, an optional mand or form object, and a model that gets passed to the view. The model will normally include the mand or form object but also arbitrary reference data. Instead, a WebWork Action bines all those roles into one single object. WebWork does allow you to use existing business objects as part of your form, but just by making them bean properties of the respective Action class. Finally, the same Action instance that handles the request gets used for evaluation and form population in the view. Thus, reference data needs to be modelled as bean properties of the Action too. Regarding views: Spring39。s JtaTransactionManager if you need distributed transactions but only then, as there are perfect replacements for single databases, like DataSourceTransactionManager or HibernateTransactionManager. Spring39。 the importation feedback model, then realization pute model control, is make model and see diagram to moderate work of parts. Usually 1 see a diagram rightness should a controller. Model, see separate of diagram and controller, make a model be able to have many manifestation to see diagram. If the customer pass a certain see the controller of diagram change the data of model, all other dependence in these see of data diagram all should reflection arrive these variety. When therefore and regardless occurrence what data variety, controller all would variety notice ally see diagram, cause manifestation of renewal. This is actually a kind of variety of modeldissemination mechanism. The Struts Frame 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 characteristic, and did according to the characteristics of J2 EE correspond of variety with expand. The Struts frame was good to bine Jsp , Java Servlet , Java Bean, Talia etc. technique. In the Struts, what to undertake the controller role in the MVC be an ActionServlet. The ActionServlet is an in general use control module. This control module provided a processing all HTTP claim which send out Struts of entrance point. Its interception with distribute these claim to arrive correspond of action type.(these action all of type is Action son type)Moreover the control module is also responsible for using to correspond of claim the parameter fill Action Form(FromBean), and pass action type(ActionBean).Action type the business logic of the interview core, then interview Java Bean or adjust to use EJB. End action type control the power pass followup of JSP document, from JSP document born see diagram. All these control logic make use of the document e to allocation. See diagram in the Struts frame main from JSP born page pletion, the Struts provide abundant of JSP label database, this is advantageous to separating performance logic and procedure model is with 1 or the form existence of several Java Bean. In the Struts, main existence three kinds of Bean, respectively BE: Action, ActionForm, EJB perhaps Java Bean. The Struts frame have no concrete definition model layer of realization, in actually the development, model layer usually is close with business logic connect with each other, and want to carry on operation to the first floor data. The underneath39。登錄的流程非常清晰:用戶從登錄頁面 ,系統(tǒng)對(duì)登錄信息進(jìn)行驗(yàn)證,如 果正確則成功登錄,否則提示相應(yīng)錯(cuò)誤信息 。 值得注意的是 , 這里沒有任何的 plugins被調(diào)用 ,因此沒有專門的集成 :來自 web 層的視圖 , 你可以簡(jiǎn)單的將 Spring 作為一個(gè)管理application context 實(shí)例入口點(diǎn)的類庫 。 對(duì)比 WebWork,Sping 更多的區(qū)別在于對(duì)象角色 :Spring 支持控制器的感念 ,一個(gè)操作命令或者 form 對(duì)象和得到數(shù)據(jù)傳遞給視圖的模式 , 這個(gè)模式通常包含命令和 form 對(duì)象 ,但有時(shí)也包含任意的參考數(shù)據(jù) 。 缺省的操作是一個(gè)非常簡(jiǎn)單的控制接口 , 他只提供了 ModelAndView handleRequest (request, response)方法 。 然而 , Spring替換 struts、 webwork 或者其他的 web 方案非常容易 。下面介紹一種開發(fā)策略,將 Hibernate引入到 Struts框架的模型層中,使用它來進(jìn)行數(shù)據(jù)封裝和映射,提供持久化的支持。另外控制組件也負(fù)責(zé)用相應(yīng)的請(qǐng)求參數(shù)填充 Action Form( FromBean),并傳給動(dòng) 作類( ActionBean)。如果用戶通過某個(gè)視圖的控制器改變了模型的數(shù)據(jù),所有其它依賴于這些數(shù)據(jù)的視圖都應(yīng)反映到這些變化。 用 Struts實(shí)現(xiàn) MVC架構(gòu) MVC( ModelViewController)由 Trygve Reenskaug提出,首先被應(yīng)用在 SmallTalk80環(huán)境中 , 是許多交互和界面系統(tǒng)的構(gòu) 成基礎(chǔ)。 Hibernate 框架 Hibernate是一個(gè)數(shù)據(jù)持 久層框架,是一種實(shí)現(xiàn)對(duì)象和關(guān)系之間映射( O/R Mapping)的工具,它對(duì) JDBC進(jìn)行了輕量級(jí)的對(duì)象封裝,