环境:
tomcat 7 + Struts 2 Spring4 MyBatis
服务端代码:
@ServerEndpoint(value = "/wsServer", configurator = GetHttpSessionConfigurator.class)
public class WsServerEndpoint {
private static final Logger LOGGER = Logger.getLogger(WsServerEndpoint.class);
private static final SimpleDateFormat TIME_FMT =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
private static Hashtable<String, Session> sessionMap = new Hashtable<String, Session>();
private static Hashtable<String, HttpSession> httpSessMap =
new Hashtable<String, HttpSession>();
/**
* 接收到连接打开请求的处理方法.
*
* @param session
* @param config
*/
@OnOpen
public void onOpen(Session session, EndpointConfig config) {
HttpSession httpSession = WsUtil.getHttpSessionFromCfg(config, "WsServerEndpoint.onClose&