Spring WebSockets中的PathVariables @SubscribeMapping不起作用

[英]PathVariables in Spring WebSockets @SubscribeMapping not working


I am trying to something similar to this "Path variables in Spring WebSockets @SendTo mapping" But I want to send a table name as additional information to @SubscribeMapping("/topic/data"). "tablename" can be anything based on my need(what I want to set), it should concatenate @SubscribeMapping("/topic/data/{tablename}") and on the server side, I would like to access the tablename to get the data from the database. I have tried the solution mentioned in the above post lien @DestinationVariable but I think I am missing something.

我正在尝试类似于“Spring WebSockets @SendTo映射中的路径变量”但我想将表名作为附加信息发送到@SubscribeMapping(“/ topic / data”)。 “tablename”可以是基于我的需要(我想要设置的),它应该连接@SubscribeMapping(“/ topic / data / {tablename}”)并且在服务器端,我想访问tablename以获取来自数据库的数据。我已经尝试过上面帖子lien @DestinationVariable中提到的解决方案,但我想我错过了一些东西。

1 个解决方案

#1


on the server side :

在服务器端:

 @SubscribeMapping("/getviewschema/{tablename}")
 public JSONObject getViewSchema(@DestinationVariable String tablename) throws Exception
 {
     DataManager manager = new DataManager();
     return manager.getViewJSONSchema(tablename);
 }

On the client side

在客户端

socket.stomp.subscribe("/app/getviewschema/"+service.tablename,function(data) 
{
        listenerview.notify(JSON.parse(data.body));
});  

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/05/08/af72673944a838c00a6cb53a3e7fe7d5.html



 
  © 2014-2022 ITdaan.com 联系我们: