LoginSignup
2
1

More than 5 years have passed since last update.

[Grails]Serviceの中でrequest、response、sessionを取得する方法

Posted at

以下の方法で取得できます。

package sample

import grails.transaction.Transactional
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
import org.codehaus.groovy.grails.web.util.WebUtils

@Transactional
class SampleService {

    def serviceMethod() {

        GrailsWebRequest webUtils = WebUtils.retrieveGrailsWebRequest()
        def request = webUtils.getCurrentRequest()
        def response = webUtils.getCurrentResponse()
        def session = webUtils.getSession()
        println request.aaa
    }
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1