Spring.net-PropertyRetrievingFactoryObject-属性为null [英] Spring.net - PropertyRetrievingFactoryObject - property is null
本文介绍了Spring.net-PropertyRetrievingFactoryObject-属性为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了解决这个问题,我正在查看我们的spring.net配置如何工作.
In an attempt to resolve this question, I'm taking a look at how our spring.net configuration works.
根本问题来自此代码段:
The root problem comes from this snippet:
<object name="someObject" singleton="false" type="SomeType.someObject, SomeAssembly">
<constructor-arg name="authSession">
<object type="Spring.Objects.Factory.Config.PropertyRetrievingFactoryObject, Spring.Core">
<property name="TargetObject" ref="AuthSessionManager" />
<property name="TargetProperty" value="CurrentAuthSession" />
</object>
</constructor-arg>
</object>
在用户未登录的情况下,AuthSessionManager.CurrentAuthSession
将为空.在这种情况下,Spring.NET会引发异常:工厂对象返回空对象".
In a case where a user is not logged in, AuthSessionManager.CurrentAuthSession
will be null. When that is the case, Spring.NET throws an exception: "Factory object returned null object".
如何告诉Spring在这种情况下可以接受空对象?
How can I tell Spring that the null object is acceptable in this case?
推荐答案
查看全文