【Jsp精品源码栏目提醒】:网学会员为广大网友收集整理了,ssh集成学习课堂笔记 - 其它资料,希望对大家有所帮助!
struts2spring jdbc 集成1、搭建 struts2 框架 a添加 struts2 类库 b在 web.xml 配置 struts2 ltfiltergt ltfilter-namegtstrutslt/filter-namegt ltfilter-classgt org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterlt/filter-classgt lt/filtergt ltfilter-mappinggt ltfilter-namegtstrutslt/filter-namegt lturl-patterngt/lt/url-patterngt lt/filter-mappinggt c在 src 下创建 struts.xml 配置文件2、添加 spring 框架 2、添加 spring 类库 基本类库: log4j-1.2.15.jar commons-logging.jar spring.jar 3、添加配置文件 log4j 配置文件 spring 配置文件 4、关系模型 create table t_user user_id int primary key auto_increment username varchar20 password varchar20 5、创建对象模型: User.java 6、在 spring 配置文件 applicationContext.xml 配置连接 DriverManagerDataSource.class 完成对数据库连接 lt-- 数据库连接 --gt ltbean idquotdataSourcequotclassquotorg.springframework.jdbc.datasource.DriverManagerDataSourcequotgt ltproperty namequotdriverClassNamequot valuequotcom.mysql.jdbc.Driverquot /gt ltproperty namequoturlquot valuequotjdbc:mysql://127.0.0.1:3306/mydbquot /gt ltproperty namequotusernamequot valuequotrootquot/gt ltproperty namequotpasswordquot valuequot1234quot/gt lt/beangt 7、完成添加 a编写数据层接口与实现 UserDaoImpl extends JdbcDaoSupport implements IUserDao b注入数据访问层 ltbean idquotuserDaoImplquot classquotcom.tarena.dao.impl.UserDaoImplquotgt lt-- dataSource 给 JdbcDaoSupport 提供 --gt ltproperty namequotdataSourcequot refquotdataSourcequot/gt lt/beangt c测试 Dao 8、spring 与 strut2 集成 a添加插件 struts2-spring-plugin-2.1.8.1.jar cspring 提供监听器管理框架在 web.xml 中配置 lt-- 配置 spring 监听器:可以和任意 web 框架集成 --gt ltlistenergt ltlistener-classgtorg.springframework.web.context.ContextLoaderListenerlt/listener-classgt lt/listenergt lt-- 制定 spring 配置文件路径 --gt ltcontext-paramgt ltparam-namegtcontextConfigLocationlt/param-namegt ltparam-valuegtclasspath:applicationContext.xmllt/param-valuegt lt/context-paramgt d在 struts.xml 中添加对 spring 支持 ltconstant namequotstruts.objectFactoryquot valuequotspringquot/gt espring 管理 struts2 的 action struts.xml 配置 ltpackagegt ltaction classquotmainActionquotgt ..... ltactiongt ltpackagegt applicationContext.xml 配置 ltbean idquotmainActionquot/gt 注意:struts.xml 文件中 classquotquot值与 applicationContext.xml 中 idquotquot值相等 2完成添加操作 lt--web--gt ltbean idquotuserActionquot classquotcom.tarena.web.action.UserActionquotgt lt-- IUserDao iuserDao new UserDaoImpl --gt ltproperty namequotiuserDaoquot refquotuserDaoImplquot/gt lt/beangt lt--dao--gt ltbean idquotuserDaoImplquot classquotcom.tarena.dao.impl.UserDaoImplquotgt ltproperty namequotdataSourcequot refquotdataSourcequot /gt lt/beangt练习顺序: 练习: spring_lesson3.4 、 spring_lesson3.6 理解: spring_lesson3.1、spring_lesson3.2、spring_lesson3.3strutsspringhibernate 框架集成1、搭建 struts 框架 1创建一个 web project 2添加 struts 类库 commons-fileupload-1.2.1.jar commons-io-1.3.2.jar freemarker-2.3.15.jar ognl-2.7.3.jar struts2-core-2.1.8.1.jar xwork-core-2.1.6.jar 3添加 struts 配置文件 在 src 下创建一个 struts.xml 配置文件 作用: 放置 struts 框架通用信息 4struts2 与 web project 集成 在 web.xml 文件中添加