我的ssh注册怎么老是提示空指针异常,this.userservice.save(users).这里提示异常<bean id="UsersDAO" class="com.ssh_demo.dao.impl.UsersDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="usersService" class="com.ssh_demo.service.impl.UsersService"
abstract="false"  lazy-init="default"
autowire="default" dependency-check="default">
<property name="usersdaoinfo">
<ref bean="UsersDAO" />
</property>
</bean> <bean name="/save" class="com.ssh_demo.struts.action.SaveAction"
abstract="false"  lazy-init="default"
autowire="default" dependency-check="default">
<property name="usersservice">
<ref bean="usersService" />
</property>
</bean>这是我的配置文件我不知道为什么会这样请大家帮忙了

解决方案 »

  1.   

    没绑定form吧this.userservice.save(usersForm.getUsers())
      

  2.   

    那说明你的this.userservice是null值
    就是你的com.ssh_demo.struts.action.SaveAction没有成功注入userservice
      

  3.   

    不需要有this啊,直接uservice.save()试试
      

  4.   

    要贴出com.ssh_demo.service.impl.UsersService的代码。貌似注入配置写得不对。
      

  5.   

    service 那个类中有没有set方法哟...
      

  6.   

    <property name="usersservice"> 
    <ref bean="usersService" /> 
    </property> 
    是不是属性对不上,或同上
      

  7.   

    如果配置文件中注入了,类中没有set方法,tomcat启动会出错,
    如果保存的时候出现null,可能是form中没有user对象,或属性未自动装配到user中,
    还有一个可能,是不是Service方法里忘了写保存方法了。 
      

  8.   

    最好先检查一下,dao,Service ,是不是都有保存方法。