问题
When being in a Grails action I can access a HTTPSession with session.
Is it also possible to get a list of all active sessions?
回答1:
You can use getSessionsInfo()
method of ScopesInfoService
service of Application Info plugin.
First install plugin(in BuildConfig)
compile ":app-info:1.0.2"{
excludes 'jquery'
}
then make an entry in Config
grails.plugins.appinfo.useContextListener = true
finally inject service and use its getSessionsInfo()
method
def scopesInfoService
...
scopesInfoService.getSessionsInfo()
to get the list of all active sessions.
回答2:
This is the answer to your question in comments:
I was able to get it work with 2.2.4, without any issue. Make sure you read this blog for compatibilities with grails 2+.
To exclude the jquery version use:
compile (":app-info:1.0.2" ){
excludes 'jquery'
}
This way your are telling Grails not to use plugins' jquery but your app.
来源:https://stackoverflow.com/questions/18161974/is-it-possible-to-get-a-list-of-all-active-sessions