后台使用的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"

});


展开全部
收起
1回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • Luna

    18人对此回答表示赞同

    同样的问题

    展开
    18
    0回复
    发布于 6年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部