日期:2014-05-17  浏览次数:20644 次

请教一道关于JSP页面上展示信息无法换行的问题
请问Json中存放的如下形式数据为什么不能再Jsp页面换行显示:
后台Action代码样例:
Java code

StringBuffer buffer = new StringBuffer();
buffer.append("This is a test");
buffer.append(System.getProperty("line.separator"));
buffer.append("This is another test");
MyObject obj = new MyObject();
obj.setSuccessRow(20);
obj.setMsg(buffer.toString());
JsonArray array = JsonArray.fromObject(obj);
JsonObject json = new JsonObject();json .put("list",array);
XXX.write(json.toString());



然后前台使用JQuery对Json数据进行解析展示,但是Msg部分的数据却没有换行显示,还是一行收尾相连方式显示。
期望显示:
成功数:20
This is a test
This is another test

实际显示:
成功数:20
This is a testThis is another test
这里为什么没有换行呢?Json数据对我的对象数据封装时做了什么处理导致我加入的换行符失去作用了吗?
请高手指点啊,多谢!

------解决方案--------------------
Java code


buffer.append("This is a test");
buffer.append(System.getProperty("line.separator"));
buffer.append("This is another test");

改成:

buffer.append("This is a test");
buffer.append("<br/>");
buffer.append("This is another test");