ERROR 15708 --- [nboundChannel-4] .WebSocketAnnotationMethodMessageHandler : Unhandled exception from message handler method.

org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException: Could not resolve method parameter at index 0 in public void com.XX.energymanagement.controller.ElectorDevsDataController.getDevsData(java.lang.String,org.springframework.messaging.simp.SimpMessageHeaderAccessor): 1 error(s): [Error in object 'reqValue': codes []; arguments []; default message [Payload value must not be empty]]

前台html代码:

stompClient.send("/app/getDevsData", {}, value);
stompClient.subscribe('/topic/devsData', function (data) {
     console.log("name --"+data.body);

后台java代码:

//reqValue-前台传入的参数
//headerAccessor 获取前台的SessionId
@MessageMapping("/getDevsData")
public void getDevsData1(String reqValue, SimpMessageHeaderAccessor headerAccessor){
    //省略业务逻辑
    messagingTemplate.convertAndSend("/topic/devsData", resultJson.toString());

错误原因

参数reqValue="" (reqValue=" "不会报错)或者reqValue=null;

检查前台代码中value值

ERROR 15708 --- [nboundChannel-4] .WebSocketAnnotationMethodMessageHandler : Unhandled exception from message handler method.org.springframework.messaging.handler.annotation.support.MethodArgumentNo... 【WebSocket】SpringBoot中,WebSocket客户端连接服务端时,出现SockJsException: Uncaught failure in SockJS...异常信息