MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 为什么小弟我的spring依赖注入不成功

为什么小弟我的spring依赖注入不成功

www.MyException.Cn  网友分享于:2013-12-03  浏览:546次
为什么我的spring依赖注入不成功?
action里执行到这句
List   reptAgilityConfigList   =   reptAgilityConfigDAO.findByProperty "localNetId ",   "351 ");
就报
严重:   Servlet.service()   for   servlet   action   threw   exception
java.lang.NullPointerException
错误。
就好象spring的配置文件没写一样。
我的action:
private   ReptAgilityConfigDAO   reptAgilityConfigDAO;

public   ReptAgilityConfigDAO   getReptAgilityConfigDAO()   {
return   reptAgilityConfigDAO;
}

public   void   setReptAgilityConfigDAO(
ReptAgilityConfigDAO   reptAgilityConfigDAO)   {
this.reptAgilityConfigDAO   =   reptAgilityConfigDAO;
}

public   ActionForward   execute(ActionMapping   mapping,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse   response)   {
UserSelectForm   userSelectForm   =   (UserSelectForm)   form;//   TODO
//   Auto-generated
//   method   stub
log.debug( "select ");
if   (userSelectForm.getUserName().equals( "abc ")
&&   userSelectForm.getPassword().equals( "123 "))   {
//   reptAgilityConfigDAO   =   new   ReptAgilityConfigDAO();
List   reptAgilityConfigList   =   reptAgilityConfigDAO.findByProperty(
"localNetId ",   "351 ");
request
.setAttribute( "reptAgilityConfigList ",
reptAgilityConfigList);
return   mapping.findForward( "initIframe ");
}
return   mapping.findForward( "input ");
}
}
applicationContext.xml:
<?xml   version= "1.0 "   encoding= "UTF-8 "?>
<!DOCTYPE   beans   PUBLIC   "-//SPRING//DTD   BEAN//EN "   "http://www.springframework.org/dtd/spring-beans.dtd ">

<beans>
<bean   id= "dataSource "
class= "org.apache.commons.dbcp.BasicDataSource ">
<property   name= "driverClassName ">
<value> oracle.jdbc.driver.OracleDriver </value>
</property>
<property   name= "url ">
<value> jdbc:oracle:thin:@133.128.9.23:1521:test </value>
</property>
<property   name= "username ">
<value> test </value>
</property>
<property   name= "password ">
<value> test* </value>
</property>
</bean>
<bean   id= "sessionFactory "
class= "org.springframework.orm.hibernate3.LocalSessionFactoryBean ">
<property   name= "configLocation ">
<value> com/hibernate.cfg.xml </value>
</property>
<property   name= "dataSource ">
<ref   bean= "dataSource "   />
</property>
</bean>
<bean   id= "ReptAgilityConfigDAO "
class= "com.yourcompany.ReptAgilityConfigDAO ">
<property   name= "sessionFactory ">
<ref   bean= "sessionFactory "   />
</property>
</bean>
<bean   name= "/userSelect "
class= "com.yourcompany.struts.action.UserSelectAction "
singleton= "false ">
<property   name= "reptAgilityConfigDAO ">

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有