PrintWriter out = getresponse().getWriter();
String str = JSONObject.fromObject(Object).toString();
//String str = JSONObject.fromObject(Array).toString();
out.writer(str);
struts1返回JSON
最新推荐文章于 2021-02-28 01:19:51 发布
本示例演示如何使用PrintWriter将JSON对象转换为字符串并输出。通过获取响应对象的PrintWriter实例,然后利用JSONObject的fromObject方法将对象或数组转换为JSON格式的字符串。
135

被折叠的 条评论
为什么被折叠?



