一、SSH—Struts2.1.8+Hibernate3.3+Spring3.0环境搭建1、Struts2.1.8集成*导入架包:commons-fileupload-1.2.1.jarcommons-io-1.3.2.jarcommons-logging-1.0.4.jarfreemarker-2.3.15.jarognl-2.7.3.jarstruts2-core-2.1.8.jarstruts2-spring-plugin-2.1.8.jar(struts+spring插件)xwork-core-2.1.6.jar*修改web.xml文件,在其中加入Struts2.1.8的配置filterfilter-namestruts2/filter-namefilter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class/filterfilter-mappingfilter-namestruts2/filter-nameurl-pattern/*/url-pattern/filter-mapping*在src目录下加入struts.xml文件(struts的配置文件),加入log4j.properties文件(用于打印日志信息)struts文件的内容:?xmlversion=1.0encoding=UTF-8?!DOCTYPEstrutsPUBLIC-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN!--constantname=struts.enable.DynamicMethodInvocationvalue=false/--constantname=struts.devModevalue=true/constantname=struts.i18n.encodingvalue=GBK/constant!--includefile=example.xml/--!--Addpackageshere--packagename=defaultnamespace=/extends=struts-default/package/struts2、Hibernate3.3集成(利用myeclipse集成开发环境来集成)*操作步凑:选中web项目,点击Myeclipse窗口中的MyEclipse--ProjectCapabilities--AddHibernateCapabilities...--点击“Next”之后如下图:点击“Next”之后如下图:点击“Next”之后如下图:到此,Hibernate3.3集成完毕3、Spring3.0集成*操作步凑:选中web项目,点击Myeclipse窗口中的MyEclipse--ProjectCapabilities--AddSpringCapabilities...--点击“Next”之后如下图:至此,Spring集成完毕4、在我们的应用中将使用数据库连接池,所以还需要加入以下架包commons-dbcp.jarmysql-connector-java-3.1.13-bin.jar(MySQL数据库驱动)commons-pool-1.4.jar现在要加入的架包都已经全部导入,接下来我们来修改配置文件Hibernate.cfg.xml文件不需要任何改动applicationContext.xml文件的配置参照如下:?xmlversion=1.0encoding=UTF-8?beansxmlns=:xsi=:p=:schemaLocation=://!--配置数据库连接池--beanid=dataSourceclass=org.apache.commons.dbcp.BasicDataSourcedestroy-method=closepropertyname=driverClassNamevaluecom.mysql.jdbc.Driver/value/propertypropertyname=urlvaluejdbc:mysql://127.0.0.1:3306/SSH2/value/propertypropertyname=passwordvaluedai/value/propertypropertyname=usernamevalueroot/value/property/bean!--配置sessionFactory--beanid=sessionFactoryclass=org.springframework.orm.hibernate3.LocalSessionFactoryBeanpropertyname=dataSourcereflocal=dataSource//propertypropertyname=mappingResourceslistvaluecom/test/bean/User.hbm.xml/value/list/propertypropertyname=hibernatePropertiespropspropkey=hibernate.dialectorg.hibernate.dialect.MySQLDialectpropkey=hibernate.show_sqltrue/prop/props/property/bean!--dao配置--beanid=userDaoclass=com.test.dao.impl.UserDaoImplscope=singletonpropertyname=sessionFactoryrefbean=sessionFactory//property/bean!--service配置--beanid=userServiceclass=com.test.service.impl.UserServiceImplscope=singletonpropertyname=userDaoref=userDao/property/bean!--action配置--beanid=saveUserActionclass=com.test.action.user.SaveUserActionscope=prototypepropertyname=serviceref=userService/property/beanbeanid=listUserActionclass=com.test.action.user.ListUserActionscope=prototypepropertyname=serviceref=userService/property/beanbeanid=removeUserActionclass=com.test.action.user.RemoveUserActionscope=prototypepropertyname=serviceref=userService/property/beanbeanid=updatePUserActionclass=com.test.action.user.UpdatePUserscope=prototypepropertyname=serviceref=userService/property/beanbeanid=updateUserActionclass=com.test.action.user.UpdateUserActionscope=prototypepropertyname=serviceref=userService/property/bean/beans我的项目包结构如下图:SSh框架配置完成,部署你的项目,启动服务器访问项目首页,如果你顺利,将看到:ThisismyJSPpage.