示例代码:
<!DOCTYPE html> <html lang="zh" xmlns:th="http://www.thymeleaf.org"> <head> <th:block th:include="include :: header('请求信息详情')"/> </head> <body class="white-bg"> <div class="wrapper wrapper-content animated fadeInRight ibox-content"> <form class="form-horizontal m" id="form-log-edit" th:object="${tbMsgLogWithBLOBs}"> <div> <textarea id="rawMessage" style="width: 100%;height: 100%" rows="16" th:text="${tbMsgLogWithBLOBs.rawMessage}" hidden></textarea> <pre id="result" style="overflow:scroll;max-height:420px;white-space: pre-wrap;word-wrap: break-word;" class="json-result" th:text="${tbMsgLogWithBLOBs.rawMessage}"></pre> </div> </form> </div> <th:block th:include="include :: footer"/> <script type="text/javascript"> $(function () { stringify(); }); function stringify() { var jsondata = $("#rawMessage").val(); var jdata = JSON.stringify(JSON.parse(jsondata), null, 4); $("#result").html(jdata);// 这时数据展示正确 } </script> </body> </html>
效果图:
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于