在Spring websocket控制器中获取Principal对象

时间:2015-10-28 17:27:44

标签: java spring model-view-controller websocket

我有一个问题,即在春季使用websockets获取当前登录的主体。 这是我的配置xml:

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

这是我的控制器方法,在没有Principal参数的情况下工作正常

@MessageMapping("/abc")
@SendTo("/showResult")
public String message(String message, Principal principal) {
    System.out.println("Principal " + principal.toString());
    return message;
}

弹簧未执行具有Principal参数的方法。当我删除Principal时,它完美无缺。当然,Spring Security在例如使用@RequestMapping注释的其他控制器

0 个答案:

没有答案
相关问题