2953关注9446浏览
后台使用的springmvc的websocket实现,但是wx_id始终是null
@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"
});
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
Luna
18人对此回答表示赞同
同样的问题
展开180回复分享发布于 6年前评论(0)
收起评论