java代码:
public void getUserNormal(HttpServletResponse resp) throws IOException {
User user = new User();
user.setId(1L);
user.setName("李明");
user.setPasswd("111111");
Object json = JSONObject.toJSON(user);
//发送json
resp.setContentType("application/json;charset=UTF-8");
//发送xml
resp.setContentType("application/json;charset=UTF-8");
//发送text
resp.setContentType("application/json;charset=UTF-8");
resp.getWriter().write(json.toString());
}