How to get the IP address when a session is created?

前端 未结 3 644
别跟我提以往
别跟我提以往 2021-01-13 08:05

In my grails application, I have implemented the interface HttpSessionListener to listen for session creation as given below:

c         


        
3条回答
  •  广开言路
    2021-01-13 08:42

    you can access the RequestContextHolder and get the value

    String ipAddr = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes())
               .getRequest().getRemoteAddr();
    

提交回复
热议问题