日期:2014-05-20  浏览次数:20720 次

我在一个action里注入两个service,为什么emaildao实现类里,拿不到session呢?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" 
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/shallow"></property>
<property name="username" value="root"></property>
<property name="password" value="tiger"></property>
<property name="maxActive" value="100"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="200"></property>
<property name="defaultAutoCommit" value="true"></property>
  </bean>
   
  <bean id="sessionFactory" 

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.baidu.model.Users</value>
<value>com.baidu.model.Email</value>
<value>com.baidu.model.REmail</value>
<value>com.baidu.model.Holiday</value>
</list>
</property>
  </bean>

  <!-- 点击登陆按钮的 -->
  <bean id="usersDao" class="com.baidu.dao.UsersDaoImpl">
  <property name="sessionFactory" ref="sessionFactory"></property>
  </bean>
  <bean id="usersServiceIn" class="com.baidu.service.UsersServiceImpl">
<property name="usersDao" ref="usersDao"></property>
  </bean>
  <bean id="Users_loginSuccess" class="com.baidu.action.UsersAction" scope="prototype">
<property name="usersServiceIn" ref="usersServiceIn"></property>
  </bean>
  <bean id="emailDao" class="com.baidu.dao.EmailDaoImpl">
  <property name="sessionFactory" ref="sessionFactory"></property>
  </bean>
  <bean id="emailServiceIn" class="com.baidu.service.EmailServiceImpl">
<property name="emailDao" ref="emailDao"></property>
  </bean>

  
  <!-- 点击个人信息保存数据的 -->
  <bean id="Users_updateSuccess" class="com.baidu.action.UsersAction" scope="prototype">
<property name="usersServiceIn" ref="usersServiceIn"></property>
  </bean>
  
  <!-- 点击显示所有数据的 -->
  <bean id="showAllUsers" class="com.baidu.action.UsersAction" scope="prototype">
<property name="usersServiceIn" ref="usersServiceIn"></property>
  </bean>