Trong grails 2.0 whats mới http://grails.org/doc/2.0.0.RC1/guide/introduction.html#whatsNew
nó nói:
1.1.3 Web Features Controller Actions as Methods It is now possible to define controller actions as methods instead of using closures as in previous versions of Grails. In fact this is now the preferred way of expressing an action.
Ví dụ:Tại sao hành động grails nên được khai báo là phương pháp thay vì đóng cửa và sự khác biệt nào?
// action as a method
def index() {
}
// action as a closure
def index = {
}
Tại sao điều này là quan trọng? Điều gì khác biệt nó làm?
CẬP NHẬT: Tôi đã tìm thấy cuộc thảo luận này thảo luận rất nhiều về phạm vi và một số nội dung đẹp mắt. http://grails.1312388.n4.nabble.com/Controller-actions-methods-or-closures-was-Re-grails-dev-Statically-typed-meta-programing-td3048287.html
Tôi đoán câu hỏi của mình cũng có thể là điều này: lợi ích của việc đóng cửa đối với hành động là gì?
Thú vị, vậy tại sao họ lại bao giờ đóng cửa? – Mikey