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

前端 未结 3 643
别跟我提以往
别跟我提以往 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:52

    You can also use this interface in your HttpSessionListener : ServletRequestListener You can implement : requestInitialized() like this.

    @Override
    public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        this.request = (HttpServletRequest) servletRequestEvent.getServletRequest();
    }
    

    it s working fine, the request object can bring you the remote adress, there is a méthod to do that

提交回复
热议问题