后台使用的springmvc的websocket实现,但是wx_id始终是null
[@Override](/user/Override)
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse arg1, WebSocketHandler arg2,
Map<String, Object> map) throws Exception {
if (request instanceof ServletServerHttpRequest) {
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
HttpServletRequest httpRequest = servletRequest.getServletRequest();
HttpSession session = httpRequest.getSession();
System.out.println(httpRequest.getParameter("wx_id")); //为什么是null?????????
if (session != null) {
map.put("user_info", httpRequest.getParameter("wx_id"));
}
}
System.out.println("连接到我了");
return true;
}
小程序代码:
wx.connectSocket({
url: ‘ws://127.0.0.1:8080/testSocket/webSocketServer.action’,
data: {
wx_id: ‘zzz’
},
header: {
‘content-type’: ‘application/json’
},
method: “GET”
});