Grails:访问请求参数而不清除它们

标签 grails web-applications

根据关于命令对象和数据绑定(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/

相关文章:

java - Grails 可以从远程目录中读取文件吗?

html - Web 应用程序入门工具包

java - Google App Engine + Java 的替代方案

objective-c - 使用 objective-c 的 Web 应用程序编程?

ios - 是否可以使用非 HTTPS URL 作为连接到 Square 的 Web 应用程序的 Web 回调 URL?

javascript - 在 Mobile Safari 下拉列表项选择框上使用 'Next' 时选择/下拉的 onchange() JS 事件的奇怪行为

grails - 如何在Grab功能测试中切换引导选项卡?

jquery - 没有真实索引的Grails索引属性

mysql - 如何使用 JDBC 更改模式以连接到 Grails 中的 MySQL?

java - 在grails中读取文件