angular - 如何订阅具有路径变量 Spring boot - Angular - Websocket - 的端点
问题描述
我正在关注几篇文章,但无法解决我的情况
场景:用户应该能够订阅具有路径变量的端点
https://spring.io/guides/gs/messaging-stomp-websocket/
https://roytuts.com/spring-boot-websocket-angularjs-gradle-example/
用法:用户将打开一个引用自定义角度组件的链接
constructor(private title: Title){
this.connection();
}
connection(){
let ws = new SockJS(this.url);
this.client = Stomp.over(ws);
let that = this;
this.client.connect({}, function(frame) {
that.client.subscribe("/topic/greeting", (message) => {
if(message.body) {
this.greeting = message.body;
$(".msg").html(this.greeting)
}
});
});
}
错误:哎呀!失去与 http://localhost:8081/.../something/89 的连接
11-10-2021 18:15:23.490 [35m[http-nio-8080-exec-3][0;39m [39mDEBUG[0;39m o.s.web.servlet.DispatcherServlet.traceDebug - GET "/api/..../89/info?t=1633972523472", parameters={masked}
11-10-2021 18:15:23.491 [35m[http-nio-8080-exec-3][0;39m [39mDEBUG[0;39m o.s.w.s.h.SimpleUrlHandlerMapping.getHandler - Mapped to ResourceHttpRequestHandler [Classpath [META-INF/resources/], Classpath [resources/], Classpath [static/], Classpath [public/], ServletContext [/]]
11-10-2021 18:15:23.492 [35m[http-nio-8080-exec-3][0;39m [39mDEBUG[0;39m o.s.o.j.s.OpenEntityManagerInViewInterceptor.preHandle - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
11-10-2021 18:15:23.502 [35m[http-nio-8080-exec-3][0;39m [39mDEBUG[0;39m o.s.w.s.r.ResourceHttpRequestHandler.handleRequest - Resource not found
默认情况下 info?t=1633972523472 被添加,似乎这给了 404 not found
我想要的是订阅端点应该是动态的 - /topic/greeting/group10 或 /topic/greeting/group20 等或任何其他模型,如请求正文获取带有 groupid 的 json
如何创建许多不同的主题?请帮忙
解决方案
推荐阅读
- python - 将浮点数组规范化到一定范围内,并在 Python 中保持符号
- image - 如何将预处理后的图像写入 kaggle 输出
- numeric - 为什么 IEEE-754 中的偏差是 127 和 1023?
- javascript - 在 GraphQL Node.js 服务器和 Nx 中的 React 之间发送数据
- python - 来自 scipy 的 solve_ivp 没有整合整个 tspan 范围
- awk - Bash/GitBash AWK 通过列名而不是列号获取列值(来自命令输出)
- icalendar - 半周活动的 RR 规则
- regex - 如何排除块中具有特定字符串条件的awk文本块
- react-native - 在 mac m1 上使用 Detox 和 Android 模拟器运行 E2E 测试
- android - 在 VS Code 中的 Flutter 项目的根项目“android”中找不到任务“assembleDebug”