0
我們可以通過servletContext(或grailsApplication)在Grails BootStrap中訪問HttpSession嗎?當用戶登錄到應用程序時,我在會話中存儲了一些信息,並在動態方法beforeInsert中使用它們。但我不知道如何在會話中檢索這些信息。
這裏是我的引導代碼:從Grails中的servletContext訪問HttpSession BootStrap
class BootStrap {
def grailsApplication
def init = { servletContext ->
grailsApplication.getArtefacts("Domain").each { org.codehaus.groovy.grails.commons.GrailsDomainClass gc ->
gc.metaClass.beforeInsert = {
// Do something here with information stored in session
}
gc.metaClass.beforeUpdate = {
// Do something here with information stored in session
}
}
}
def destroy = {
}
}
謝謝你這麼多