首先 順序?qū)?spring hibernate struts
配置applicationContet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="datasource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="jdbcUrl"
value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=blog;SelectMethod=cursor">
</property>
<property name="user" value="sa"></property>
<property name="password" value="sa"></property>
<property name="minPoolSize" value="5"></property>
<property name="maxPoolSize" value="20"></property>
<property name="acquireIncrement" value="5"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="datasource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>

<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/zcq/dao</value>
</list>
</property>
</bean>
<!-- hibernateTemplate 配置 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- zcqbb datable -->
<bean id="daoimp" class="com.zcq.dao.Test" >
<property name="hibernateTemplate" ref="hibernateTemplate" />
</bean>
</beans>
然后寫接口
然后實(shí)現(xiàn)接口
package com.zcq.job.dao;

import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.zcq.job.I.Zcq_I;

public class Zcq_Imp extends HibernateDaoSupport implements Zcq_I {

public void show() {
System.out.println("sssssss");
}
public static Zcq_I getApplication(ApplicationContext ctx)
{
return (Zcq_I)ctx.getBean("daoimp");
}
}
web.xml 里加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>gbk</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
配置applicationContet.xml



















































然后寫接口
然后實(shí)現(xiàn)接口


















web.xml 里加入






















