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 个解决方案


on the server side :


 public JSONObject getViewSchema(@DestinationVariable String tablename) throws Exception
     DataManager manager = new DataManager();
     return manager.getViewJSONSchema(tablename);

On the client side





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