2017-07-05 54 views
-1

我有簡單的web套接字:爲什麼映射websocket不工作?

@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"):無論在註釋@ServerEndpoint("/chat")("bla-bla")值始終工作只有root瀏覽器:

enter image description here

我的註釋。 enter image description here

如何將瀏覽器的URL更改爲http://localhost:8080/PsiNavigator/chat? 謝謝。

+0

它是不可變的,因爲在運行時改變它是沒有意義的,但這不是你實際要求的。你在問爲什麼你現在的靜態,不可變映射不起作用。 – EJP

+0

@EJP沒有我的靜態目前是工作看到第一個屏幕,但聊天總是映射到根。這是問題。 – Pavel

回答

相關問題