Ajax常用工具
来源:互联网 发布:sql数据库语法 编辑:程序博客网 时间:2024/06/15 03:42
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
public class AjaxUtil
{
public static String AJAX_RETURN_OBJECT="ajaxReturnObject";//dont change this
public static String AJAX_RETURN_VIEW="ajaxReturnView";//dont change this
public static String bean2Json(Object bean){
JSONObject jsonobj=JSONObject.fromObject(bean);
String jsonStr=jsonobj.toString();
return jsonStr;
}
public static void printf(AjaxResponseDTO bean, HttpServletResponse response) {
response.setContentType("text/Xml;charset=UTF-8");
response.setHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);
PrintWriter out = null;
try {
out = response.getWriter();
out.print(AjaxUtil.bean2Json(bean));
} catch (IOException e) {
} finally {
if (null != out)
out.close();
}
}
public static String listToJson(List<?> list) {
StringBuilder json = new StringBuilder();
json.append("[");
if (list != null && list.size() > 0) {
for (Object obj : list) {
json.append(bean2Json(obj));
json.append(",");
}
json.setCharAt(json.length() - 1, ']');
} else {
json.append("]");
}
return json.toString();
}
}
0 0
- Ajax常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 常用工具
- 关于Android开源库与设计模式开源组建立
- html dom
- 新的项目管理工具-java
- ON_COMMAND/ON_MESSAGE/ON_NOTIFY区别与联系 【转】
- chtml/ChinaHtml标签能把节点内容保存为文件
- Ajax常用工具
- 进程权限
- android 画图之setXfermode
- Codeforces C. Registration system
- Linux下挂载windows下的共享目录
- Canvas---Canvas图像加载、利用javascript回调机制实现一个图片加载器
- robotium—只有apk文件的测试
- 【装逼专用】说出来很拽的互联网排行
- iOS学习笔记(6)——适配器(Adapter)模式