pom.xml引入依赖,如果没有用maven,在lib里加入相应jar即可
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.0.1.RELEASE</version>
<scope>provided</scope>
</dependency>
web端
<script type="text/javascript">
var websocket=null;
if('WebSocket' in window){
websocket = new WebSocket("ws://localhost:86/Maya_Map/websocketForMap");
}
else{
alert("当前浏览器不支持websocket&#