有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Requestcontextholder在spring 4中具有并发访问权限。IBMWebSphere上的x Web应用程序?

在我的春天4。x项目使用spring安全认证和授权,我们在所有控制器请求映射方法中使用Requestcontextholder获得请求、会话和响应

public static HttpServletRequest getCurrentRequest() {
    ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
    return servletRequestAttributes.getRequest();
}

public static HttpSession getCurrentSession() {
    return getCurrentRequest().getSession();
}

public static HttpServletResponse getCurrentResponse() {
    ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
    return servletRequestAttributes.getResponse();
}

根据定义,RequestContextHolder被定义为“Holder类,以线程绑定的RequestAttributes对象的形式公开web请求。”但我不确定“线程绑定”是否代表线程安全

我们有一个问题,当两个用户有两个活动会话时,会话不知何故发生了交叉,一个用户能够看到其他用户的详细信息。我们怀疑从来自Requestcontextholder的请求中获取属性并不是web请求线程安全的

现在来问一个问题,一个线程是否有可能访问另一个线程的requestContext


共 (0) 个答案