【发布时间】:2016-05-13 23:04:24
【问题描述】:
从ServletRequestAttributes 对象请求属性值时,如何知道为scope 参数提供什么值?
特别是,我想获取发送到this GitHub example app 的授权端点的请求的_csrf 属性的值。我设置了一个CustomOAuth2RequestFactory 以包含对ServletRequestAttributes.getAttribute("_csrf", scope) 方法的调用,但是我如何知道输入什么值作为scope 以获得正确的_csrf 值?
另外,我找到了this link to the Spring documentation for bean scopes,但是应该如何引用上面显示的方法调用中的范围之一?只需输入作用域的字符串名称,就会在 eclipse 中出现编译错误警告,因为它试图将字符串作为 int 传递。
【问题讨论】:
-
这些不是 bean 范围。它们是 Servlet 范围(请求/会话)的抽象。常量在
RequestAttributes接口中定义。使用适当的请求或会话。
标签: java spring spring-mvc spring-security spring-boot