根据关于命令对象和数据绑定(bind)的文档。一旦你读取了 params 对象,这个对象就不能再被重用了。
从文档中:
将请求体绑定(bind)到命令对象
http://grails.org/doc/2.3.x/guide/theWebLayer.html#commandObjects
Note that the body of the request is being parsed to make that work. Any attempt to read the body of the request after that will fail since the corresponding input stream will be empty. The controller action can either use a command object or it can parse the body of the request on its own (either directly, or by referring to something like request.JSON), but cannot do both.
我正在尝试查看过滤器中的参数(在请求 Controller 之前命中)。将参数记录到日志会导致 Controller 获取空参数对象吗?从看起来是这种情况的文档中。但是,我怎样才能访问参数而不在过滤器中清除它们?
最佳答案
Once you read the params object, that object can never be reused again.
这是不正确的。您可以一遍又一遍地读取请求参数。不能一遍又一遍地阅读的是请求的正文。正文和请求参数是两个不同的东西。
关于Grails:访问请求参数而不清除它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27158409/