收藏
回答

小程序websocket data中参数后台接收不到

后台使用的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 个回答

  • Faith
    Faith
    2018-09-04

    同样的问题

    2018-09-04
    有用
    回复
登录 后发表内容