h4. Returning the Modelh4. 返回模型(Model)A model is essentially a map that the view uses when rendering. The keys within that map translate to variable names accessible by the view. There are a couple of ways to return a model, the first way is to explicitly return a map instance:模型(Model)本质上是个map类型,当视 ...
h4. Available Scopesh4.可用范围(Scopes)Scopes are essentially hash like objects that allow you to store variables. The following scopes are available to controllers:范围(Scopes)本质上就像hash对象,允许你存储变量。下列为controllers(控制器)可用范围(Scopes):* [servletContext|controllers] - Also known as application scope, this scope ...
h4. Creating a controllerh4. 创建控制器(Controllers)Controllers can be created with the [create-controller|commandLine] target. For example try running the following command from the root of a Grails project:控制器(Controllers)可以使用[create-controller|commandLine]目标来创建.作为示例可以在Grails根目录下尝试运行下列命令。{code:java}gra ...
A controller handles requests and creates or prepares the response and is request-scoped.  In other words a new instance is created for each [request|controllers]. A controller can generate the response or delegate to a view. To create a controller simply create a class whose name ends with @Co ...
翻译自《Groovy in action》,如有不准确之处,希望指教! closures(闭包)很重要,非常的重要!!!可以被认为是Groovy中一个非常有用的特性。同时,在你没有完全了解它之前会是一个陌生的概念。为了发挥Groovy最大功效,或者了解任何其他Groovy代码,它将肯定让你感觉轻松。不只是“一次婚礼上遇见它们”的轻松,而是“邀请它们参加周末烧烤”的轻松。(注原文: Not just “met them once at a wedding” comfortable, but “invit ...
h4. Using the render method to output XML h4. 使用render输出XML Grails' supports a few different ways to produce XML and JSON responses. The first one covered is via the [render|controllers] method. Grails提供一些不同的方法来产生XML和JSON响应。第一个是隐式的通过[render|controllers]方法。 The @render@ method can be passed a bl ...