1,<wbr></wbr><wbr></wbr>在Struts<wbr></wbr>中所有的jsp<wbr></wbr>文件本来是有Action<wbr></wbr>自己进行管理和处理的。现在由Spring<wbr></wbr>进行管理,但是处理还是仍然靠自己里面的Action<wbr></wbr>进行处理。所以在Struts-config.xml<wbr></wbr>中必须设置它的监听类,<wbr></wbr><controller<wbr></wbr><wbr></wbr>processorClass="org.springframework.web.struts.DelegatingRequestProcessor"><wbr></wbr><wbr></wbr></controller><wbr></wbr>2,<wbr></wbr><wbr></wbr>因为现在由Spring<wbr></wbr>进行管理所有的Action,<wbr></wbr>所有的Action<wbr></wbr>在Srping <wbr></wbr>就应该进行初始化<wbr></wbr><bean name="/login" class="com.yxj.oa.login.LoginAction"><wbr></wbr> <property name="loginDao"><wbr></wbr><ref local="LoginDao"/><wbr></wbr> </property><wbr></wbr>
</bean>
3,由以上两点可以得出,Struts-config.xml中必须加载Spring的applicationContext.xml<wbr></wbr><!--加载applicationContext.xml-->
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
4,HibernateTemplate的配置:<wbr></wbr><!--<wbr></wbr>把连接池放在这里配置,<wbr></wbr>便于移植,最后这个配置会移到spring配置文件中去--><wbr></wbr> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><wbr></wbr><property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"></property><wbr></wbr><property name="url" value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=officAuto"></property><wbr></wbr><property name="username" value="sa"></property><wbr></wbr><property name="password" value="123"></property><wbr></wbr> </bean><wbr></wbr> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><wbr></wbr><property name="dataSource"><wbr></wbr> <ref local="dataSource"/><wbr></wbr></property><wbr></wbr><property name="hibernateProperties"><wbr></wbr> <props><wbr></wbr><prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop><wbr></wbr><prop key="hibernate.show_sql">true</prop><wbr></wbr> </props><wbr></wbr></property><wbr></wbr><property name="mappingResources"><wbr></wbr> <list><wbr></wbr><value>com/yxj/oa/usermanage/Userinfo.hbm.xml</value><wbr></wbr> </list><wbr></wbr></property><wbr></wbr> </bean><wbr></wbr><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><wbr></wbr><property name="sessionFactory"><wbr></wbr> <ref local="sessionFactory"/><wbr></wbr></property><wbr></wbr> </bean><wbr></wbr>5,<wbr></wbr>所以在dao<wbr></wbr>中只需要这样调用下就可以了
<bean id="UserDao" class="com.yxj.oa.usermanage.UserDao"><wbr></wbr> <property name="hibernateTemplate"><wbr></wbr><ref local="hibernateTemplate"/><wbr></wbr> </property><wbr></wbr></bean><wbr></wbr>6,在dao中要去继承import org.springframework.orm.hibernate3.support.HibernateDaoSupport;<wbr></wbr>HibernateDaoSupport<wbr></wbr>
<wbr></wbr>