为什么映射websocket不起作用?

时间:2017-07-05 00:20:19

标签: java websocket

我有简单的网络套接字:

tbls <- c("tbl_r3_300ft", "tbl_r4_350ft", "tbl_r5_400ft", 
          "tbl_r6_500ft", "tbl_r7_600ft", "tbl_r8_700ft", 
          "tbl_r9_800ft", "tbl_r10_900ft", "tbl_r11_1000ft", 
          "tbl_r12_1200ft", "tbl_r13_1400ft", "tbl_r14_1600ft", 
          "tbl_r15_1800ft", "tbl_r16_2000ft")

sql <- "SELECT Col1, Col2, Col3 FROM" 

dfList <- lapply(paste(sql, tbls), function(s) {
             tryCatch({ return(dbGetQuery(my_db, s)) 
                      }, error = function(e) return(as.character(e)))
          })

# ROW BIND VERSIONS ACROSS PACKAGES
master_df <- base::do.call(rbind, dfList)
master_df <- plyr::rbind.fill(dfList)
master_df <- dplyr::bind_rows(dfList)
master_df <- data.table::rbindlist(dfList)

但我的查看聊天页面@ServerEndpoint("/chat") public class ChatEndpoint { @OnMessage public void onMessage(final Session session, final String msg) { try { cashing(session, msg); newsletter(session, msg); } catch (IOException e) { e.printStackTrace(); } } } 始终映射到根index.jsp。当我尝试添加到路径http://localhost:8080/PsiNavigator时,我得到/chat。无论注释404@ServerEndpoint("/chat")中的值是什么,始终只能在浏览器中使用root:

enter image description here

我的注释是:("bla-bla")在两个屏幕上。 enter image description here

如何将浏览器的网址更改为@ServerEndpoint("/chat")? 谢谢。

1 个答案:

答案 0 :(得分:1)

我必须使用ws协议访问你的websocket端点而不是http。

我建议你按照这个有用的tuto来展示如何构建一个完整的websocket应用程序示例(后端和前端)。 http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html