浏览 795 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-12-04
Grails 1.0-RC2 发布,看到新增不少功能,心中窃喜啊
现在简介一下主要变动:
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
xml: ['text/xml', 'application/xml']
// etc.
]
那么在处理这个请求的时候,可以使用withFormat方法: def list = {
def results = Book.list()
withFormat {
html bookList:result
xml { render results as XML }
}
}
<book>
<title>The Stand</title>
<author>Stephen King</author>
...
</book>
那在controller中可以这样使用: def save = {
def b = new Book(params['book'])
if(b.save()) {
// deal with book
}
}
class Book {
Author author
static mapping = {
columns {
author column:'auth_id'
}
}
}
你也可以单向的one-to-many或者many-to-many关联的join table和columns,比如: class Author {
static hasMany = [books:Book]
static mapping = {
columns {
books joinTable:[name:'authors_books', key:'book_id', column:'author_id']
}
}
}
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
| 返回顶楼 | |
|
时间:2007-12-04
更新下来试下 不知道会不会还是有RC1一样 会频繁的让我重启服务器 |
|
| 返回顶楼 | |
|
时间:2007-12-04
|
|
| 返回顶楼 | |
|
时间:2007-12-04
agile_boy, 你动作很快呀 :)
可惜我感兴趣的特性都在Grails1.1。 |
|
| 返回顶楼 | |
|
时间:2007-12-04
你们也太快拉,呵呵
今天总算拿到Grails权威指南了 |
|
| 返回顶楼 | |
|
时间:2007-12-04
我也很期待1.0正式版的到来,希望Grails更加稳定
|
|
| 返回顶楼 | |








