struts1和struts2及数据库连接(小结)

Sturts1:核心控制器ActionServlet(org.apache.struts.action.ActionServlet),继承DispatchAction(struts.jar)

Dao层:(ibatis)继承spring.jarSqlMapClientDaoSupport

Sturts2:核心控制器FilterDispatcher(org.apache.struts2.dispatcher.FilterDispatcher),继承ActionSupport(xwork.jar)

Dao层:(hibernate)继承spring-orm.jarHibernateDaoSupport

SprintMVCDispatcherServlet(org.springframework.web.servlet.DispatcherServlet)

Dao层:1.springjdbc SimpleJdbcTemplate

2.hibernateSimpleHibernateDao


注:1:spring配置文件:datasource+sessionFattory   连接数据库

2:daoimpl:数据库操作

(1) struts1+ibatis (hnzw)

(2) struts2+hibernate(ssh:简单-find ; wop:复杂-session.createSQLQuery -多数据源; hm_dzjc:复杂-this.createQuery-注解-)  单数据源:hm_dzjc,hnzw,ssh;

  多数据源(连接池):wop

(3) springMVC(hm_dzjc:springjdbc)

spring容器,BeanFactoryApplicationContext




1.jdbc
2.jdbc加载配置文件
3.jdbc加载proxool.xml(连接池)
4.hibernate
5.spring加载hibernate
6.spring加载配置文件(可单一,可多)- JNDI(dataSource)
7.spring加载proxool.xml(多,连接池)} - web.xml中加载proxool.xml
8.spring加载Ibatis - SqlMap只是用来映射,还需web.xml中用proxool



hibernate读取:

(

1.

2.


)


spring容器:


spring配置文件默认位置为/WEB-INF/下,这时在web.xml中可不用配置(路径),若在classpath下,则需要在web.xml中配置;

struts2配置文件默认路径为classpath下。



web.xml:

spring:

<!-- Spring配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring/*.xml</param-value> </context-param>

 <!--Spring context loader(Struts2的Spring支持)-->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
struts2:
<filter>
		<filter-name>struts2</filter-name>
		<filter-class>
			org.apache.struts2.dispatcher.FilterDispatcher
		</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值