首页 > 代码库 > DWZ-JUI Ajax.post 封装
DWZ-JUI Ajax.post 封装
/**
* dwz ajax post
* @author taller
*
*/
public class DwzAjaxResult {
private String statusCode;
private String message;
private String navTabId; //如果设置的话可以在返回回来的时候重新加载那个navtab,就是把那个navtab刷新一遍。
private String rel;
private String callbackType; //回调函数 如果是closeCurrent就会关闭当前tab
private String forwardUrl; //客户端可以重新调转到某个界面 只有callbackType="forward"时需要forwardUrl值
private String confirmMsg;
private String closeDialog="";//添加关闭dialog属性
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getNavTabId() {
return navTabId;
}
public void setNavTabId(String navTabId) {
this.navTabId = navTabId;
}
public String getRel() {
return rel;
}
public void setRel(String rel) {
this.rel = rel;
}
public String getCallbackType() {
return callbackType;
}
public void setCallbackType(String callbackType) {
this.callbackType = callbackType;
}
public String getForwardUrl() {
return forwardUrl;
}
public void setForwardUrl(String forwardUrl) {
this.forwardUrl = forwardUrl;
}
public String getConfirmMsg() {
return confirmMsg;
}
public void setConfirmMsg(String confirmMsg) {
this.confirmMsg = confirmMsg;
}
public String getCloseDialog() {
return closeDialog;
}
public void setCloseDialog(String closeDialog) {
this.closeDialog = closeDialog;
}
public static void josnMessage(DwzAjaxResult dwz){
JSONArray arrParent = new JSONArray();
JSONObject object = new JSONObject();
object.put("statusCode", dwz.getStatusCode());
object.put("message", dwz.getMessage());
object.put("navTabId", dwz.getNavTabId());
object.put("rel",dwz.getRel());
object.put("callbackType", dwz.getCallbackType());
object.put("forwardUrl",dwz.getForwardUrl());
object.put("confirmMsg", dwz.getConfirmMsg());
object.put("closeDialog", dwz.getCloseDialog());
arrParent.add(object);
String jsonStr = JsonUtils.toJSON(arrParent).replace("[","").replace("]","");
HttpServletResponse response = ServletActionContext.getResponse();
response.setHeader("Pragma", "No-Cache");
response.setHeader("Cache-Control", "No-Cache");
response.setDateHeader("Expires", 0);
try {
response.setCharacterEncoding("utf-8");
response.getWriter().write(jsonStr);
} catch (IOException e) {
e.printStackTrace();
}
}
DWZ-JUI Ajax.post 封装