我按照这个https://github.com/rstoyanchev/spring-websocket-portfolio和这个 http://assets.spring.io/wp/WebSocketBlogPost进行了与Spring 4,STOMP和sock.js的简单Web套接字通信。 html
好吧,我想知道是否可能捕获连接事件,例如何时将新客户端连接到我的服务器或何时断开客户端的连接事件,在Spring 4.0.0中是否可能?
我开始使用 Vuex 来替换 EventBus,因为我的应用程序中的数据开始变得有点复杂。
在我的上下文中,我有一个问题实体,有多个答案,当用户插入另一个答案时,我想显示最后一个答案;(这里我使用两个不同的组件:一个用于显示答案,另一个用于回答问题)但是当服务器对新答案做出正确响应并且突变更改了 state.answers 时,计算属性不会做出反应并且不会' t 显示新答案:
这是我的数据结构:
"answers": {
"118": {
"id": 118,
"description": "objective",
"created_at": "2019-11-12T19:12:36.015Z",
"dojo_process_id": 1,
"question_id": 1,
"user_id": 10
}
"127": {
"id": 127,
"description": "asdddd",
"created_at": "2019-11-12T19:38:19.233Z",
"dojo_process_id": 1,
"question_id": 1,
"user_id": 10
},
"128": {
"id": 128,
"description": "asddddasddd",
"created_at": "2019-11-12T20:00:17.572Z",
"dojo_process_id": 1,
"question_id": 1,
"user_id": 10
}
},
Run Code Online (Sandbox Code Playgroud)
这是我的商店的代码:
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
...
answers: {},
... …Run Code Online (Sandbox Code Playgroud) 我有一个使用Spring和jaxb的Web服务,我尝试在某些情况下抛出一个异常,为此我使用了anotation @WebFault.像这样:
@WebFault
public class ServiceException extends Exception {
private static final long serialVersionUID = -5307754615848423430L;
private FaultBean faultBean;
public ServiceException(String message, ServiceErrorCode serviceErrorCode) {
super(message);
this.faultBean = new FaultBean();
this.faultBean.setMessage(message);
this.faultBean.setErrorCode(serviceErrorCode);
}
public FaultBean getFaultInfo() {
return faultBean;
}
Run Code Online (Sandbox Code Playgroud)
}
它的工作正常,这是输出:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>myException</faultstring>
<detail>
<ns2:ServiceException xmlns:ns2="http://soap.service.test/">
<errorCode>UNRECOGNIZED_ERROR</errorCode>
<message>myException</message>
</ns2:ServiceException>
<ns2:exception class="ServiceException" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false" xmlns:ns2="http://jax-ws.dev.java.net/">
<message>myException</message>
<ns2:stackTrace>
<ns2:frame class="myWebService" file="myWebService.java" line="50" method="listTickets"/>
<ns2:frame class="sun.reflect.NativeMethodAccessorImpl" file="NativeMethodAccessorImpl.java" line="native" method="invoke0"/> …Run Code Online (Sandbox Code Playgroud) java ×2
spring ×2
javascript ×1
mutation ×1
spring-mvc ×1
vue.js ×1
vuex ×1
web-services ×1
websocket ×1