为什么不在Json响应中添加消息,如错误消息

时间:2015-02-12 18:32:47

标签: moqui

如果我使用' web-send-json-response =" true"'在调用任何服务时,它使用WebFacadeImpl.groovy的sendJsonResponse(Object responseObj)方法返回json响应。 它增加错误的地方'如果' eci.getMessage()。hasError()'真正。但是,有没有理由为什么不在Json Response中添加消息?

由于我愿意在json响应中有消息,所以我在sendJsonResponse()方法中添加了几行。 代码块我添加了几行来向json响应添加消息:

} else if (responseObj != null) {
    responseObj.put("messages", eci.message.messages)
    JsonBuilder jb = new JsonBuilder()
    jb.call(responseObj)
    jsonStr = jb.toString()
    response.setStatus(HttpServletResponse.SC_OK)
} else {
    jsonStr = ""
    if (eci.message.messages) {
        responseObj.put("messages", eci.message.messages)
        JsonBuilder jb = new JsonBuilder()
        jb.call(responseObj)
        jsonStr = jb.toString()
    }
    response.setStatus(HttpServletResponse.SC_OK)
}

它工作正常,我在json响应中收到消息。

0 个答案:

没有答案