【发布时间】:2017-12-21 15:03:52
【问题描述】:
我的 java 代码有一个超级代理调用。在那个 Java 控制器中 - 我正在抛出用户定义的异常消息,如下所示。
服务中:
if (user_id == null){
throw new Exception("User ID is missing!!!");
}
在控制器中:
Map<String, String> resp = new HashMap<String,String>();
try{
String returnValue= myserviceobj.myservicemethod;
}catch(Exception e){
resp.put("status","ERROR");
resp.put("message",e.getMessage());
return new ResponseEntity<Map<String,String>>(resp, HttpStatus.Bad_Response);
}
在 React Js 中,我使用 superagent 进行服务调用。我不确定如何在 UI 中访问该用户定义的异常消息。
这是我在 JS 中所做的:
webservice(data, actionName, (error,resp){
if(error){
//call alert and send the user defined message.
}
})
【问题讨论】:
-
您的意思是您希望添加警报组件或类似服务处理程序的东西?
-
在 JS 端我必须在警报中显示该消息
-
请查看更新后的答案。
标签: javascript java reactjs