• Scope 'session' is not active for the current thread《转》


    1、问题一

    用struts2做查询,当不同客户端查询时,a端会看到b端的查询结果,导致原因scope="singleton"

    解决方法:

    要将bean中的scope设置成“session【session作用域的bean则对每次http Session有效

    <bean id="assetAction" class="com.servicezone.itsd.asset.webapp.action.AssetAction"scope="session"
    <property name="assetManager" ref="assetManager"/> 
    <property name="itProductManager" ref="itProductManager"/> 
    <property name="vendorManager" ref="vendorManager"/> 
        </bean>
    于是出现如下异常

    2、问题二

    Struts Problem Report

    Struts has detected an unhandled exception:

    Messages:
    1. No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
    2. Error creating bean with name 'qAction': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
    3. Unable to instantiate Action, qAction, defined for 'qshow' in namespace '/'Error creating bean with name 'qAction': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
    File: org/springframework/web/context/request/RequestContextHolder.java
    Line number: 131

    Stacktraces

    Unable to instantiate Action, qAction, defined for 'qshow' in namespace '/'Error creating bean with name 'qAction':Scope 'session' is not active for the current thread;consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
        com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
        com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)

    解决方法

    (1)当使用了Spring's DispatcherServlet以外的Servlet 2.4及以上的Web容器时(如使用JSF或Struts),你需要在Web应用的'web.xml'文件中增加 javax.servlet.ServletRequestListener 定义
    <web-app>
      ...
      <listener>

        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>

      </listener>
      ...
    </web-app>
    (2)如果你用的是早期版本的web容器(Servlet 2.4以前的版本),那么你要使用一个javax.servlet.Filter的实现。请看下面的web.xml配置片段:

    <web-app>
      ..
      <filter> 
        <filter-name>requestContextFilter</filter-name> 
        <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
      </filter> 
      <filter-mapping> 
        <filter-name>requestContextFilter</filter-name> 
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      ...
    </web-app>


    转自--http://blog.csdn.net/woshirongshaolin/article/details/8251062
  • 相关阅读:
    在Win7 64位电脑上安装Sql Server 2008 R2 Express
    尝试u盘重装系统
    摘自《北方人》
    编写一个换算GPA 的Application 程序,对于学生学习的每门课程,都输入两个整数:考试成绩和学分,考试成绩按如下公式换算: 85~100:4 75~84:3 60~74:2 45~59:1 44以下:0 GPA等于换算后每门课的成绩的学分加权平均值
    java编程题
    生成器并发处理其实就是函数的切换
    生成器与文档结合
    生成器函数
    生成器表达式、三元表达式、列表解析
    迭代,列表,字典,文件迭代
  • 原文地址:https://www.cnblogs.com/auto714/p/2935732.html
Copyright © 2020-2023  润新知