struts,spring,hibernate整合方式技术文章
方式1: 1在struts-config.xml中所有的action的class全部写成org.springframework.web.struts.DelegatingActionProxy 2在spring.xml中配置action 3在struts-config.xml文件中配置plug-in 方式2: 1 在web.xml中的节点中加上 contextConfigLocation WEB-INF/classes/com/xaccp/config/spring.xml context org.springframework.web.context.ContextLoaderServlet 1 2 配置struts-config.xml中的 3 在spring.xml中配置 方式3: 在src下新建一个包如com.xaccp.config中放置action-servlet.xml,hibernate.cfg.xml,spring.xml 三个文件 在action-servlet.xml文件中全部放置真正的action的包名和类名,其中完成IOC的注入 如: 在hibernate.cfg.xml中放置所有数据库的设置 如 org.hibernate.dialect.SQLServerDialect jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=HR_DB sa com.microsoft.jdbc.sqlserver.SQLServerDriver DBM true 在spring.xml中配置DAO和事务等 如: WEB-INF/classes/com/xaccp/config/hibernate.cfg.xml 最后在struts-config.xml中设置action和plug-in 如: 其中在spring.xml中的session WEB-INF/classes/com/xaccp/config/hibernate.cfg.xml 不用再在spring.xml中配置数据源和sessionFactory了,可以直接使用hibernate.cfg.xml配置的信息