器将数据封装成 Form 对象,根据业务流决定是交给下一个业 务逻辑进行处理还是返回到页面 控制器是按 struts-config. xml 文件中的配置来决定业务流的转向的,struts-config.xml 的 部分代码如下: <struts-config> <data-sources/> <form-beans> <form-beanname="loginForm"type="com.struts. form.LoginForm"/> </form-beans> <action-mappings> <action parameter="operate" attribute="loginForm" name="loginForm" path="/userAction" scope="request" > <forwardname="index"path="/index.jsp"/> <forwardname="success"path="/success.jsp"/> <forwardname="error"path="/error.jsp"/> <forwardname="r_success"path="/r_success.jsp"/ > <forwardname="register"path="/register.jsp"/> </action> </action-mappings> <controller> <set-propertyproperty="processorClass"value=" org.springframework.web.struts.DelegatingRequestProcessor" /> </controller> <message-resourcesparameter="com.struts. ApplicationResources"/> <plug-inclassName="org.springframework.web.struts. ContextLoaderPlugIn"> <set-propertyproperty="contextConfigLocation" value="classpath:applicationContext.xml"/> </plug-in> </struts-config> 4 结语 网站以开源框架 Spring 框架为核心,向下整合 Hibernate 进行持久层访问,向上整合 Struts 按清晰的 MVC 模式控制, 清晰地划分了应用的层次,提高系统灵活性,降低了维护成 本 通过实体关系映射工具将关系型数据库的数据映射成对 象,很方便地实现以面向对象方式操作数据库,该系统采用 Hibernate 作为 ORM 框架 Spring 的作用贯穿了整个中间层, 将 Web 层 Service 层 DAO 层及 PO 无缝整合,其数据服务 层用来存放数据 通过使用 Hibernate 持久层,可以避免使用 传统的 JDBC 操作数据库,对 JDBC 进一步包装,从而更好地 使用面向对象的方式来操作数据库 保证了整个软件开发过 程以面向对象的方式进行 利用 Struts+Spring+Hibernate 框架开发网站,使网站具有 良好的可维护性和可扩展性。 |