JSONObject把对象转换成的json字符串,无法直接通过request.setAttribute();传到页面的input标签
如下是错误的:
request.setAttribute(“pageInfoJsonStr”, JSONObject.fromObject(pageInfo).toString());
还需要 jsonStr.replaceAll(“\”“, “’”)再放到request.setAttribute中
本文探讨了将Java对象转换为JSON字符串,并将其传递到页面过程中遇到的问题。具体介绍了使用JSONObject进行转换时,如何避免直接设置到request属性导致无法正确显示在input标签中的情况。
JSONObject把对象转换成的json字符串,无法直接通过request.setAttribute();传到页面的input标签
如下是错误的:
request.setAttribute(“pageInfoJsonStr”, JSONObject.fromObject(pageInfo).toString());
还需要 jsonStr.replaceAll(“\”“, “’”)再放到request.setAttribute中
3753

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