• 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>

     
     
  • 相关阅读:
    2-5
    2-4 及 1、2两章 学习心得 和问题
    2-3
    4-8
    4-6
    4-5
    4-4
    4-3
    4-2
    4-1
  • 原文地址:https://www.cnblogs.com/qbzf-Blog/p/6538486.html
Copyright © 2020-2023  润新知