Java 在spring websocket控制器中获取主对象

Java 在spring websocket控制器中获取主对象,java,spring,model-view-controller,websocket,Java,Spring,Model View Controller,Websocket,我有一个麻烦,就是在春季使用WebSocket获取当前登录的principal。 以下是我的配置xml: <websocket:message-broker> <websocket:stomp-endpoint path="/ws"> <websocket:sockjs/> </websocket:stomp-endpoint> <websocket:simple-broker/> </we

我有一个麻烦,就是在春季使用WebSocket获取当前登录的principal。 以下是我的配置xml:

<websocket:message-broker>
    <websocket:stomp-endpoint path="/ws">
        <websocket:sockjs/>
    </websocket:stomp-endpoint>
    <websocket:simple-broker/>
</websocket:message-broker>

spring未执行具有主参数的方法。当我删除Principal时,它工作得非常好。当然,Spring安全性在以@RequestMapping注释的rest控制器中正常工作,您看过吗@jny是的,但这在普通http控制器方法中很有用。在这里,我使用WebSocket,但在本例中它不起作用,我尝试使用SimpMessageHeaderAccessor.getUser(msg.getHeaders())并返回null,所以我想我在spring安全配置方面有问题。我应该添加一些东西(比如拦截器)来让它工作吗?
@MessageMapping("/abc")
@SendTo("/showResult")
public String message(String message, Principal principal) {
    System.out.println("Principal " + principal.toString());
    return message;
}