纠结了好几天,发现自己基础基础知识都丢干净了.
在参照这个demo:https://blog.csdn.net/moshowgame/article/details/80275084的时候,由于我使用的模板引擎是thymeleaf.后端使用modelAndView传值,而前端html接收参数方式书写有误,导致一直接收不到参数.
错误如下:
不正确html书写:
<input id ="cid" type="hidden" value="${cid}" >
经过查阅网上博客后才想起,thymeleaf应该这样书写标签:
<html>标签中增加
<html xmlns:th="http://www.w3.org/1999/xhtml">
接收参数标签写为th:value:
<input id ="cid" type="hidden" th:value="${cid}" >
修改后,webSockect连接正常: