Java Spring安全性:如何在applicationContext.xml中获得授权用户
对不起我的英语。如何在applicationContext.xml中获取授权用户 身份验证类别: 并在文件applicationContext.xml中:Java Spring安全性:如何在applicationContext.xml中获得授权用户,java,spring,spring-security,Java,Spring,Spring Security,对不起我的英语。如何在applicationContext.xml中获取授权用户 身份验证类别: 并在文件applicationContext.xml中: <bean id="Authentication" class="com.otv.util.Authentication"> </bean> <bean id="CurrentAccount" factory-bean="Authentication" factory-method="g
<bean id="Authentication" class="com.otv.util.Authentication">
</bean>
<bean id="CurrentAccount"
factory-bean="Authentication"
factory-method="getAccount"/>
<bean id="Authentication" class="com.otv.util.Authentication"/>
<bean id="CurrentAccount" factory-bean="Authentication" factory-method="getAccount" scope="request">
<aop:scoped-proxy/>
</bean>
<bean id="PostPaginatorDTO" class="com.otv.model.dto.paginator.PostPaginatorDTO" scope="request">
<property name="account" ref="CurrentAccount" />
</bean>
我猜您正在尝试创建一个bean,它的作用域不是默认的,而是singleton。使用范围属性。如果想在单例bean中使用作用域bean,最好也使用作用域代理
@sergeyivanov错误看起来有点不相关。搜索TransientObjectException,或者问一个新问题?
<bean id="Authentication" class="com.otv.util.Authentication"/>
<bean id="CurrentAccount" factory-bean="Authentication" factory-method="getAccount" scope="request">
<aop:scoped-proxy/>
</bean>
<bean id="PostPaginatorDTO" class="com.otv.model.dto.paginator.PostPaginatorDTO" scope="request">
<property name="account" ref="CurrentAccount" />
</bean>
@ManagedProperty(value="#{PostPaginatorDTO}")
public PostPaginatorDTO paginatorDTO;
public List<Post> getEntityList() {
entityList=getDao().findByPostPaginatorDTO(getPaginatorDTO());
return entityList;
}