Spring报错——Scope 'session' is not active for the current thread

在对程序进行了一些修改后,运行发现spring报了这个错误,这是由于我设置了一个@Scope("session")导致的,现记录下解决方法。

解决方法:

将Scope设置为scope="session"需要在web.xml中做一下设置打开session机制:

<!-- 开启Session机制 -->
<listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

 

如果单单加入以上一条还不行的话,那就在相应的spring bean配置中加入<aop:scoped-proxy/>,如:

<bean id="xxxx" class="xxx" scope="session">
  <aop:scoped-proxy/>
</bean>

 
 
posted @ 2017-03-12 17:17  薄峰  阅读(3541)  评论(1编辑  收藏  举报