Websocket - httpSession returns null

前端 未结 4 1334
小鲜肉
小鲜肉 2020-12-18 21:22

I would like to make the connection between a websocket handshake \\ session to a HttpSession object.

I\'ve used the following handshake modification:



        
4条回答
  •  旧时难觅i
    2020-12-18 21:32

    Building on @pavel-bucek 's answer, I wrote a simple HttpSessionInitializerFilter servlet filter.

    Just download the jar from the "Releases" page and save it anywhere in the classpath, then add the following snippet to your web.xml descriptor (modify the url-pattern as needed):

    
      HttpSessionInitializerFilter
      net.twentyonesolutions.servlet.filter.HttpSessionInitializerFilter
    
    
    
      HttpSessionInitializerFilter
      /ws/*
    
    

提交回复
热议问题