我使用tomcat 7.0.77,spring,現在sockjs無法打開信息。 的web.xmlsockjs信息404錯誤
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/cmd/*</url-pattern>
<url-pattern>/webSocketServer</url-pattern>
<url-pattern>/sockjs/webSocketServer/*</url-pattern>
<url-pattern>/sockjs/webSocketServer/info</url-pattern>
<url-pattern>/webSocketServerLogout</url-pattern>
<url-pattern>/webSocketServerSpAlarm</url-pattern>
的java
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// registry.addHandler(systemWebSocketHandler(),"/webSocketServer").addInterceptors(new WebSocketHandshakeInterceptor());
registry.addHandler(systemWebSocketHandler(), "/sockjsWebSocketServer").addInterceptors(new WebSocketHandshakeInterceptor())
.withSockJS();
catalina.out中 INFO:映射的URL路徑[/ sockjs/webSocketServer/**]到類型的處理程序[類org.springframework.web.socket .sockjs.support.SockJsHttpRequestHandler] 2017年7月17日下午1點01分46秒org.springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler
HTML
websocket = new SockJS("http://"+local+"/sockjs/webSocketServer");
首先不能打開/ sockjs/webSocketServer /信息當我添加/ sockjs/webSocketServer /信息到像上面的web.xml, http://172.24.170.178/sockjs/webSocketServer/093/vl3vnd0p/websocket 404錯誤
感謝報告
catalina.out報告2017年7月17日上午5點14分28秒org.springframework.web.servlet.PageNotFound noHandlerFound 警告:在名爲'mvc'的DispatcherServlet中未找到具有URI [/ sockjsWebSocketServer/info]的HTTP請求的映射-dispatcher」 – johnie