Grails get Session and Management in Service class

前端 未结 4 1732
囚心锁ツ
囚心锁ツ 2021-02-04 04:11

I have a problem with Grails Session. I was thinking about having a Service Class for my session handling. So I created a class called \"SessionService\" (under grails-app/servi

4条回答
  •  再見小時候
    2021-02-04 05:10

    For new versions (>2.2) of Grails:

    import org.codehaus.groovy.grails.web.util.WebUtils
    
    ....
    HttpServletRequest request = WebUtils.retrieveGrailsWebRequest().currentRequest
    HttpSession session = request.session
    

提交回复
热议问题