有人可以回答我的问题吗?
我想部署一个Web应用程序文件夹
C:\app\myapp
Run Code Online (Sandbox Code Playgroud)
到Tomcat6.x而不是副本
%TOMCAT_HOME%\webapps
Run Code Online (Sandbox Code Playgroud)
tomcat服务器上需要哪些配置?
谢谢
尝试使用sockjs在套接字上使用Spring 4 WebSocket和STOMP.我遇到了一个问题.
我的配置:
websocket.xml - spring上下文的一部分
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/ws">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic"/>
</websocket:message-broker>
Run Code Online (Sandbox Code Playgroud)
控制器代码:
@MessageMapping("/ws")
@SendTo("/topic/ws")
public AjaxResponse hello() throws Exception {
AjaxResponse ajaxResponse = new AjaxResponse();
ajaxResponse.setSuccess(true);
ajaxResponse.addSuccessMessage("WEB SOCKET!!! HELL YEAH!");
return ajaxResponse;
}
Run Code Online (Sandbox Code Playgroud)
客户端:
var socket = new SockJS("<c:url value='/ws'/>");
var stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
alert('Connected: ' + frame);
stompClient.send("/app/ws", {}, {});
stompClient.subscribe('/topic/ws', function(response){
alert(response.success);
});
});
Run Code Online (Sandbox Code Playgroud)
输出:
Opening Web Socket... stomp.js:130
GET http://localhost:8080/ws/info 404 (Not Found) sockjs-0.3.js:807
Whoops! Lost connection to undefined …Run Code Online (Sandbox Code Playgroud) 所以我必须说所有的websocket教程/示例看起来都很简单,但是你似乎真的需要挖掘才能找到简单例子中遗漏的非常重要的信息.我的webapp使用前端有SockJS的Spring 4 Stomp消息代理,我有很多问题.
目前,如果我在没有启用SockJS()的情况下向StompEndpointRegistry添加端点,然后使用dojo的dojox/socket在前端声明我的套接字,Firefox 28将打开websocket就好了.但是,我需要在IE8和IE9中支持,所以我切换到了SockJS.使用AbstractAnnotationConfigDispatcherServletInitializer,我花了很多时间来弄清楚如何确保所有过滤器和servlet都设置为使用异步(在Web上非常稀疏的文档).一旦我解决了这个问题,我现在可以在Firefox中使用它,但只能使用xhr_streaming.将sessionCookieNeeded设置为true,IE9默认尝试使用iframe进行连接,但是,它失败:
LOG: Opening Web Socket...
LOG: Opening transport: iframe-htmlfile url:rest/hello/904/ft3apk1g RTO:1008
LOG: Closed transport: iframe-htmlfile SimpleEvent(type=close, code=1006, reason=Unable to load an iframe (onload timeout), wasClean=false)
LOG: Opening transport: iframe-xhr-polling url:rest/hello/904/bf63eisu RTO:1008
LOG: Closed transport: iframe-xhr-polling SimpleEvent(type=close, code=1006, reason=Unable to load an iframe (onload timeout), wasClean=false)
LOG: Whoops! Lost connection to undefined
Run Code Online (Sandbox Code Playgroud)
如果我将所需的cookie设置为false,IE将使用xdr-streaming并正常工作,但是,它会丢失请求中的jsessionid cookie,反过来我失去了在控制器中获取Principal的能力,这对我来说很重要.我在spring security中启用了相同的origin x frame header,我已经验证了请求中是否存在标题,但它没有帮助.所以我想知道如何A)让Spring和SockJS在Firefox中使用WebSocket传输正确协商,并且B)让IE8和9正确使用iframe传输,这样我就可以保留cookie.
这是我的配置/代码:
网络应用配置:
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
Map<String, ? …Run Code Online (Sandbox Code Playgroud)