/**
* 异步请求响应回写
*
* @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);
}
}
}
}
异步请求响应回写
最新推荐文章于 2023-12-15 13:11:49 发布