未将对象引用设置到对象实例,又名空指针异常,伴随程序员开发的一生.
查看详细信息得知: SetUserRoleInfo()
首先想到的是 IBLL.IRoleInfoService RoleInfoService { set; get; }应该是config文件中反射出现了问题
<?xml version="1.0" encoding="utf-8" ?> <objects xmlns="http://www.springframework.net"> <!--控制器--> <object type="BBFJ.OA.WebApp.Controllers.UserInfoController, BBFJ.OA.WebApp" singleton="false" > <!--控制器的属性--> <property name="UserInfoService" ref="userInfoService" /> </object> <object type="BBFJ.OA.WebApp.Controllers.LoginController, BBFJ.OA.WebApp" singleton="false" > <!--控制器的属性--> <property name="UserInfoService" ref="userInfoService" /> </object> <object type="BBFJ.OA.WebApp.Controllers.RoleInfoController, BBFJ.OA.WebApp" singleton="false" > <!--控制器的属性--> <property name="RoleInfoService" ref="roleInfoService" /> </object> <!--intentionally do NOT register the AccountController or the ValuesController with the container; demonstrates that the underlying default controller factory will properly (attempt to!) resolve all controllers not registered with Spring.NET using its default controller resolution behavoir--> <!--<object type="Spring.Mvc4QuickStart.Controllers.AccountController, Spring.Mvc4QuickStart" singleton="false" />--> <!--<object type="Spring.Mvc4QuickStart.Controllers.ValuesController, Spring.Mvc4QuickStart" singleton="false" />--> </objects> <?xml version="1.0" encoding="utf-8" ?> <objects> <object type="BBFJ.OA.BLL.UserInfoService, BBFJ.OA.BLL" singleton="false" name="userInfoService"> </object> <object type="BBFJ.OA.BLL.RoleInfoService, BBFJ.OA.BLL" singleton="false" name="roleInfoService"> </object> </objects>
检查过后发现毛病
<object type="BBFJ.OA.WebApp.Controllers.UserInfoController, BBFJ.OA.WebApp" singleton="false" >
<!--控制器的属性-->
<property name="UserInfoService" ref="userInfoService" />
<property name="RoleInfoService" ref="roleInfoService" />
</object>