The recent integration of WebSocket into the project, open Web pages will always encounter such errors.
There are 3 reasons for saying this online, but they are not for me, but they are also recorded.
1.struts2 intercepted the WS request. This invocation can attempt to empty the Web. XML, which is the problem if it can be connected. At this point, add the following in the Struts.xml configuration file:
<name= "Struts.action.excludePattern" value= "ws://*" ></constant>
The request to WS is not intercepted.
2.jar package conflict, the jar package in the project conflicts with the jar package in Tomcat.
3. Turn Java project into Web project and adjust the package load order.
Then it's your solution, the URL rule for the WS request is this: Address + port +endpoint path. If the endpoint is defined in a Java file:
@ServerEndpoint (value= "/echoendpoint")
and runs on local 8080 port, the URL is http://127.0.0.1:8080/echoendpoint
Java7 WebSocket only need to configure endpoint, the page JS can be connected, no servlet or other configuration, just pay attention to the next URL.
Struts2+websocket error: Failed:error during WebSocket handshake:unexpected response code:404