在 Spring 拦截器中访问 DWR 发布数据
我有一个带有方法签名的 DWR 操作,如下所示:
String joinGroup(String groupId, String groupName);
这是通过 DWR AJAX 请求调用的,并且工作正常。
但是,我正在尝试编写一个 Spring 拦截器(工作方式与 ServletFilter 非常相似)来在调用 DWR 操作之前执行一些身份验证工作。
拦截器被正确调用,但我需要访问拦截器中的 groupId 和 groupName 数据。
请求参数映射为空,我已经在调试器中浏览了整个请求属性列表,但在任何地方都看不到数据。
请求的 postData 也为 null。
使用 firebug 我可以看到数据正在传递到服务器(当最终调用 joinGroup 方法时它就在那里)。
我似乎无法在拦截器中访问它。
我有什么办法可以访问它吗?
I have a DWR action with a method signature as follows:
String joinGroup(String groupId, String groupName);
This is called via a DWR AJAX request and works fine.
However, I am trying to write a Spring interceptor (works much like a ServletFilter) to do some authentication work before the DWR action is called.
The interceptor is being called correctly but I need to access the groupId and groupName data in the interceptor.
The request parameter map is empty and I've been through the entire list of request attributes in a debugger and I can't see the data anywhere.
The request's postData is null also.
Using firebug I can see the data is being passed to the server (and it's there when the joinGroup method is ultimately called).
I just can't seem to access it in my interceptor.
Is there any way I can access it at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 org.directwebremoting.AjaxFilter
每次在配置此过滤器的方法上发出 Ajax 请求时,DWR 都会调用 AjaxFilter 的 doFilter 方法。 传入此方法的 AjaxFilterChain 允许过滤器将方法详细信息传递到链中的下一个实体。
通常,该方法将执行以下操作:
Use org.directwebremoting.AjaxFilter
The doFilter method of the AjaxFilter is called by DWR each time an Ajax request is made on a method that this filter is configured against. The AjaxFilterChain passed in to this method allows the filter to pass on method details to next entity in the chain.
Typically the method would do the following:
我假设您使用 MethodInterceptor ,它仅在上述方法上被调用(意味着您的配置是正确的)。
Spring框架中的MethodInterceptor与Spring Security中的MethodSecurityInterceptor几乎完全相同。
I will assume you you using a MethodInterceptor which is getting called (meaning your config is correct) only on the above method.
MethodInterceptor in the Spring Framework is pretty much the exact same as MethodSecurityInterceptor in Spring Security.