双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

急!!!spring整合问题

Tito10 Tito10 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
请问下大家,为什么我用struts执行到action里面,业务层的对象要通过在struts-config.xml里面配置个
<controller>
<set-property perty="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor" />
</controller>
才能被实例化呢?

现在我进到了业务层的方法里面,dao的对象又没有实例化了,要怎么配置才能让dao实例化呢?下面是我applicationContext.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="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="url"
value="jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=letDB">
</property>
<property name="username" value="sa"></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>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yyun/struts/pojo/hbm/UserInfo.hbm.xml</value>
<value>com/yyun/struts/pojo/hbm/ReleaseInfo.hbm.xml</value></list>
</property></bean>

<!-- DAO层 -->
<bean id="UserInfoDAO" class="com.yyun.struts.dao.UserInfoDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="ReleaseInfoDAO"
class="com.yyun.struts.dao.ReleaseInfoDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<!-- 业务逻辑层 -->
<bean id="userManageService"
class="com.yyun.struts.serivce.impl.UserInfoServiceImp">
<property name="userInfoDao">
<ref local="UserInfoDAO" />
</property>
</bean>

<!-- 定义事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!-- 声明式事务切面(AOP) -->
<bean id="txProxyTemplate"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target" ref="userManageService"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="do*">PROPAGATION_REQUIRED</prop>
<prop key="reg*">PROPAGATION_REQUIRED</prop>
<prop key="login*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>

<!-- 生成的动态代理类 -->
<bean id="custProxy" parent="txProxyTemplate">
<property name="target">
<ref bean="userManageService"/>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
</bean>

<bean name="/reg" class="com.yyun.struts.action.UserAction">
<property name="biz">
<ref local="custProxy"/>
</property>
</bean>
</beans>
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
Tito10
Web 开发 81,108 成员 341,721 内容