【发布时间】:2016-11-14 08:38:12
【问题描述】:
我按照教程在我的 Java Spring 应用程序中实现 websockets。 到目前为止它运行良好,但我真的很想了解它的用途:
config.setApplicationDestinationPrefixes("/app");
我的整个配置看起来像这样
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello").withSockJS();
}
}
我基本上只是不明白 spring docs / the tut 中给出的解释 - 例如
...它为绑定到@MessageMapping-annotated 方法的消息指定“/app”前缀。
【问题讨论】: