spring注入提示空指针异常,求指点 5
publicclassUserActionextendsBaseAction<User>{UserDaoImpluserImpl;publicvoidsetUserImp...
public class UserAction extends BaseAction<User>{
UserDaoImpl userImpl;
public void setUserImpl(UserDaoImpl userImpl) {
this.userImpl = userImpl;
public String find(){
User user=userImpl.find(hql);
return "loginSuccess"; }
}
spring里配置文件包括下面的部分
<bean id="userDaoImpl" class="com.bo.daoImpl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userAction" class="com.bo.action.UserAction" >
<property name="userImpl" ref="userDaoImpl"></property>
</bean>
提示如下空指针
java.lang.NullPointerException
com.bo.action.UserAction.find(UserAction.java:37) 展开
UserDaoImpl userImpl;
public void setUserImpl(UserDaoImpl userImpl) {
this.userImpl = userImpl;
public String find(){
User user=userImpl.find(hql);
return "loginSuccess"; }
}
spring里配置文件包括下面的部分
<bean id="userDaoImpl" class="com.bo.daoImpl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userAction" class="com.bo.action.UserAction" >
<property name="userImpl" ref="userDaoImpl"></property>
</bean>
提示如下空指针
java.lang.NullPointerException
com.bo.action.UserAction.find(UserAction.java:37) 展开
1个回答
2013-12-08
展开全部
使用的bean是 userImpl;
配置的是 userDaoImpl;
把两个名字改成一样的
配置的是 userDaoImpl;
把两个名字改成一样的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询