Grails Controller - 动态方法文档

标签 grails controller

我想知道找出哪些动态方法添加到某些变量的最佳方法是什么。我没有看到它记录在 documentation或 Controller 类的 javadoc。

一个例子是 grails Controller 中的 params 对象:

params.int('max') 

int 方法被注入(inject),我想知道这个特定 map 有哪些额外的方法可用。

最佳答案

我得到了 的副本Grails 2 权威指南 几天前,正如这里所说,原始类型有 8 种转换方法:

... Grails provides convenience methods for doing this type of conversion on request parameters. Those methods are available on the params object and have names that correspond to all eight of the primitive types defined by Java (Boolean, byte, char, short, int, long, float and double). The methods each accept one or two arguments. The first argument is the name of the request parameter that is to be converted, and the optional second argument is a default value that will be returned if a corresponding request parameter cannot be found or if an error occurs during the conversion ...



并且还提到了一种名为list的转换方法。 :

... Another type of converting method is named list. The list method is useful when dealing with multiple request parameters of the same name ...



布朗, J. S., Rocher, G., (2013)。 Grails 权威指南 2。纽约:Apress。

国际标准书号:978-1-4302-4377-9

Amazon

我希望引用它不会违反任何版权...

是的,我认为书籍是一个很好的问题来源,我肯定会推荐 Grails 2 权威指南 致您或任何其他想要更深入地了解 Grails 的程序员。此外,Grails Mailing ListsGroovy Zone dzone.com 上的内容是任何 Grails 相关问题和/或新闻的好资源。 Groovy JDK documentation正如@doelleri 在他的回答中提到的那样,这也很有帮助。

关于Grails Controller - 动态方法文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14754485/

相关文章:

grails - 让 Groovy 成功!

grails - 线程 “main”中的异常java.lang.ClassNotFoundException:使用grails 3.0.0在Intellij中使用org.codehaus.groovy.grails.cli.support.GrailsS​​tarter

javascript - Angular Controller $scope.fId 显示未定义的值

c# - 如何在 Sitecore 中的 Sitecore.Context.Item.Database 项上设置数据库详细信息

grails - 在 Grails 域类中使用继承

grails - RestfulController 没有在 POST 中绑定(bind)嵌套的 JSON

grails - 在grails服务中手动回滚

php - PHP MVC原则

php - 在哪里加载 Controller 依赖类?

Codeigniter缓存 Controller 问题