67,540
社区成员
发帖
与我相关
我的任务
分享String data="[{\"judge\":"a"}]";
String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
[/quote]
他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行[/quote]嗯,我知道,就是感觉挺麻烦的,谢谢你了!
[/quote]
他只是过滤特殊字符 ,写个公用的方法 。你的字符串都扔进去过滤一下,在放到json里就行

String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
[/quote]
你要ajax输出给客户端?这样的话你用json-lib就是了
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();[/quote]但是刚刚发现这么用的话,前台的回调函数无法回调成功啊!
[/quote]其实是我自己的代码写错了,木事木事!
String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
[/quote]
你要ajax输出给客户端?这样的话你用json-lib就是了
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();[/quote]但是刚刚发现这么用的话,前台的回调函数无法回调成功啊!
<h3><font color="blue">这里是数据测试</font></h3>
<p>sdf </p>
这样是通不过的!

String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
[/quote]
你要ajax输出给客户端?这样的话你用json-lib就是了
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();[/quote]非常霸气,我以前一直想用工具就是不知道工具的使用具体方法,刚刚用了一下,行得通,非常感谢!
String content =new String("<h3><font color="blue">这里是数据测试</font></h3><p>sdf </p>");
String data="[{\"judge\":"+content+"}]";
你觉得将上面的data能以json的格式传过去吗?
[/quote]
你要ajax输出给客户端?这样的话你用json-lib就是了
response.setContentType("application/json;charset=utf-8");
PrintWriter pw=response.getWriter();
String content ="<h3><font color=\"blue\">这里是数据测试</font></h3><p>sdf </p>";
JSONObject jo=new JSONObject();
jo.accumulate("judge", content);
JSONArray ja=new JSONArray();
ja.add(jo);
pw.write(ja.toString());
pw.flush();
pw.close();