簡體   English   中英

Spring WebSockets @SubscribeMapping中的PathVariables不起作用

[英]PathVariables in Spring WebSockets @SubscribeMapping not working

我正在嘗試與此類似的內容“ Spring WebSockets @SendTo映射中的路徑變量 ”,但我想將表名稱作為附加信息發送到@SubscribeMapping(“ / topic / data”)。 “ tablename”可以是任何基於我的需要(我想設置的東西)的東西,它應該將@SubscribeMapping(“ / topic / data / {tablename}”)連接起來 ,在服務器端,我想訪問該表名以獲取數據庫中的數據。 我已經嘗試了上述留置權@DestinationVariable中提到的解決方案,但我認為我缺少一些東西。

在服務器端:

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

在客戶端

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM