---
title: "ajax返回"
author: "sric08"
date: "2011-05-27T09:22:49Z"
tags: ["Ajax", "Cache", "Java", "XML", "json"]
categories: ["Web前端"]
slug: "ajax"
draft: false
lastmod: "2011-05-27T09:22:49Z"
id: 1060629
url: "https://sric08.iteye.com/blog/1060629"
---

```
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
	out = response.getWriter();
out.println("输出信息"); //输出信息常用json对象或为json数组，当然用string也可以啦，随便你
out.flush();
```

 

 

返回jsonObject

```
out.println(new JSONObject());//或者out.println(new java.util.HashMap());
```

 

返回 jsonArray

```
org.json.JSONArray jsonArray = new org.json.JSONArray();
jsonArray.put(new java.util.HashMap()); //或者 jsonArray.put(org.json.JSONObject());
out.println(jsonArray.toString());
```