/**
* 异步请求响应回写
*
* @param json
* @throws ECApplicationException
*/
private void writeAjax(String json) throws ECApplicationException {
String methodName = "writeAjax";
Writer writer = null;
logger.logp(Level.SEVERE, CLASSNAME, methodName, json);
try {
// 获取响应对象,此处可以根据不同的框架结构,进行调整
HttpServletResponse response = (HttpServletResponse) ((ViewCommandContext) this.context)
.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
writer = response.getWriter();
writer.write(json);
writer.flush();
} catch (Exception e) {
logger.logp(Level.SEVERE, CLASSNAME, methodName, e.toString(), e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
logger.logp(Level.SEVERE, CLASSNAME, methodName, e1.toString(), e);
}
}
}
}
比如微信支付成功后回写,让微信那边不用再回调了
//告诉微信订单成功不用回调了
res.getWriter().write(WxPayCore.generatePaySuccessReplyXML());
原作者地址http://blog.csdn.net/xieshengjun2009/article/details/18797497