1.理解Flash Scope
// 存储一个消息在flash范围 fash.message = 'I am available next time you request me!'
当这个消息被下一个消息覆盖时就自动销毁
2.访问请求参数
def userName = request.getParameter('userName') log.info("User Name: ${userName}")
简单写法
def userName = params.userName log.info("User Name: ${userName}")
3.请求参数的类型转换
def index() { // since params.counter is a string, it must be converted to an int if // the application intends to use the value as a number def counter = params.counter.toInteger() // … }
使用int类型转换
def index() { def counter = params.int('counter') // … }
使用list类型转换
def index() { for (name in params.list('name') { // do something with name } }