日期:2014-05-16  浏览次数:21114 次

关于Spring 注解 空指针问题 跪求前辈帮忙啊
Action中:
      
   @Service
   @Scope("prototype")
   public class LoginAction extends BaseAction{
   private AdminInfo adminInfo;
   private String errorMsg;
   @Resource
   private AdminInfoDao amdinInfoDao;

   @Transactional(readOnly=true)
   public String execute(){
              AdminInfo a=amdinInfoDao.
     findByAdminCodeAndPassword("admin","111111");
             //此处amdinInfoDao报空指针异常
           }

DAO中:
     @Repository
     public class AdminInfoDaoImpl extends BaseDao implements AdminInfoDao{
      //BaseDao中已经配置了sessionFactory
      @Override
      public AdminInfo findByAdminCodeAndPassword(String adminCode,
                   String password) throws DaoException{...}
           }


web.xml中:
    有引入Spring配置:
           <context-param> 
               <param-name>contextConfigLocation</param-name>
              <param-value>classpath:applicationContext-*.xml</param-value>
           </context-param>
     <!-- 在启动服务器时,实例化Spring容器 -->
   <listener>
        <listener-class>
          org.springframework.web.context.ContextLoaderListener
        </listener-class>
  </listener>
  
    <filter>
     <filter-name>
                  openSessionInviewFilter
          </filter-name>
     <filterclass>
                org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          </filter-class>
  </filter>
  
  <filter>
       <filter-name>Struts2</filter-name>
       <filterclass>                       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
       </filter-class&g