<%@ page contentType="text/html; charset=UTF-8" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%
String path =request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=basePath %>js/jquery-1.9.1.js"></script> <style type="text/css">
.table-result{
width:100%;
border:1px solid #f2f2f2;
text-align:left;
border-collapse: collapse;
}
.table-result th{
height:40px;
font-weight: normal;
font-size:14px;
line-height:22px;
text-align:center;
background-color:#f0f0f0;
border-right:2px solid #fff;
color:#4e4e4e;
border-style: solid;
border-width: 1px;
border-color: gray;
}
.table-result td{
text-align:center;
height:40px;
font-size:12px;
line-height:22px;
color:#4e4e4e;
border-style: solid;
border-width: 1px;
border-color: gray;
padding-left: 2px;
padding-right:2px;
}
td
{
white-space:nowrap; }
</style>
</head>
<body style="width: 100%;overflow: scroll;"> <form action="upload!view.dhtml" method="post" style="margin-left:10px;">
<h2>原始记录</h2>
<textarea id="origrec" rows="5" cols="80">${logQueryDataModel.origrec }</textarea>
<h2>最新记录</h2>
<textarea id="lastrec" rows="5" cols="80">${logQueryDataModel.lastrec}</textarea>
</form>
</body>
</html>
<script>
$(document).ready(function(){ $("textarea").each(function(i){
var p = $(this).text();
if($.trim(p)=="") $(this).replaceWith("");
if(p!="\n\t\n\t"){
var json;
try{
json = JSON.parse(p);
var id="";
if($(this).attr("id")!= null)
id="id="+$(this).attr("id");
var t1="<table class=table-result "+id+" ><thead><tr>";
var flag=0;
var tr1="<tr>";
for(var j in json)
{
if(flag>0)
{
t1+="<tr>";
}
for(var item in json[j])
{
if(flag==0)
{
if(item!="")
t1+="<th class=center style='font-size:10px;height:15px;width:100%;'>"+item+"</th>";
tr1+="<td align=center style='height:15px;width:100%;'>"+json[j][item]+"</td>";
}else
{
t1+="<td align=center style='height:15px;width:100%;'>"+json[j][item]+"</td>";
}
}
if(flag==0)
t1+="</tr></thead>"+tr1+"</tr>";
else
t1+="</tr>";
flag++;
}
$(this).replaceWith(t1);
}catch(e)
{
}
}
});
var flag = 0;
$("textarea").each(function(i){
$(this).prev().remove();
$(this).remove();
flag+=1;
});
if(flag==2)
{
$("form").html("<h3>(此操作无详细数据)</h3>");
}
if(flag==1)
{
var ts = $("table[id$=rec]");
for(var i=0;i<ts.length;i+=2)
{
for(var c=0;c<ts[i].rows[1].cells.length;c++)
{
var a = ts[i].rows[1].cells[c].innerText;
var b = ts[i+1].rows[1].cells[c].innerText;
if(a!=b)
{
ts[i].rows[1].cells[c].style.backgroundColor='gray';
ts[i].rows[1].cells[c].style.color='white';
ts[i+1].rows[1].cells[c].style.backgroundColor='gray';
ts[i+1].rows[1].cells[c].style.color='white';
}else if(a==""&&b=="")
{
ts[i].rows[0].cells[c].style.display='none';
ts[i+1].rows[0].cells[c].style.display='none';
ts[i].rows[1].cells[c].style.display='none';
ts[i+1].rows[1].cells[c].style.display='none';
}
}
}
}
}); </script>

  

JSON数据转换成table表格的更多相关文章

  1. 【转】C#中将JSon数据转换成实体类,将实体类转换成Json

    http://wo13145219.iteye.com/blog/2022667 http://json2csharp.chahuo.com/ using System; using System.C ...

  2. 利用JAVA反射机制将JSON数据转换成JAVA对象

    net.sf.json.JSONObject为我们提供了toBean方法用来转换为JAVA对象, 功能更为强大,  这里借鉴采用JDK的反射机制, 作为简单的辅助工具使用,   有些数据类型需要进行转 ...

  3. 将JSON数据转换成JAVA的实体类

    思路:首先将JSON格式的数据转换成JSONObject,然后将JSONObject转换成Java的实体类(其中类属性包括List等类型) Java实体类: SearchFilter 类 1 publ ...

  4. python - 将数据转换成 excl 表格, json 等文件 (dajngo - 打开网页后自动下载)

    本篇只讲述怎么用. 具体 tablib  更多详细用法可参考博客 : https://blog.csdn.net/liangyuannao/article/details/41476277 # 不得不 ...

  5. 怎么把后台传过来的Json拼成table 用Jquery ajax()

    页面上的表格定义:<table id="tableId"></table> js中的代码:var $parent0 = $('#tableId);//获取页 ...

  6. 把HDFS里的json数据转换成csv格式

      1. 全景图 2. 用ListHDFS获取所有文件名   如果想重新再取一次,右健view state:   点击 clear state, 再运行,即可再次采集数据了.   3. 用FetchH ...

  7. 【转】参照protobuf,将json数据转换成二进制在网络中传输。

    http://blog.csdn.net/gamesofsailing/article/details/38335753?utm_source=tuicool&utm_medium=refer ...

  8. C#实现调用接口数据获取数据格式化XML、json转成Table的方法

    废话不多说,直接上代码: json 格式化转DataTable: result为从接口得到的数据,格式化json的方法主要来自Newtonsoft.Json JObject joUnit = JObj ...

  9. 把json数据转换成集合

    Sting MessageList="";JSONArray json = JSONArray.fromObject(MessageList);JSONObject object ...

随机推荐

  1. BFC(块级格式化上下文)

    渲染规则 1.内部的box会在垂直方向,一个接一个的放置 2.box垂直方向的距离由margin决定,属于同一个bfc的两个相邻box的margin会发生重叠 3.每个元素的margin box的左边 ...

  2. 洛谷 P1957 口算练习题 题解

    题目传送门 这道题是考字符串处理,另外输入要使用c++的cin的神奇功能. #include<bits/stdc++.h> using namespace std; int n;char ...

  3. 湖南大学ACM程序设计新生杯大赛(同步赛)I - Piglet treasure hunt Series 1

    题目描述 Once there was a pig, which was very fond of treasure hunting. The treasure hunt is risky, and ...

  4. 洛谷P4139 上帝与集合的正确用法 [扩展欧拉定理]

    题目传送门 上帝与集合的正确用法 题目描述 根据一些书上的记载,上帝的一次失败的创世经历是这样的: 第一天, 上帝创造了一个世界的基本元素,称做“元”. 第二天, 上帝创造了一个新的元素,称作“α”. ...

  5. mycat数据库中间件入门

    首先从官网上下载mycat. 官网链接 下载对应的mycat即可. 我也是小白一个,就是直接在window上操作了. 自己画的,真low. 推荐一篇文章 https://blog.csdn.net/u ...

  6. python中对list去重的多种方法

    今天遇到一个问题,用了 itertools.groupby 这个函数.不过这个东西最终还是没用上. 问题就是对一个list中的新闻id进行去重,去重之后要保证顺序不变. 直观方法 最简单的思路就是: ...

  7. Spring Cloud项目启动脚本

    #!/bin/bash source /etc/profile cd `dirname $0` BIN_DIR=`pwd` echo "$BIN_DIR"#项目名称 SERVER_ ...

  8. SCOJ 4484 The Graver Robbers' Chronicles 后缀自动机

    4484: The Graver Robbers' Chronicles 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4484 Descript ...

  9. Educational Codeforces Round 10 B. z-sort 构造

    B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school fo ...

  10. CDOJ 1292 卿学姐种花 暴力 分块 线段树

    卿学姐种花 题目连接: http://acm.uestc.edu.cn/#/problem/show/1292 Description 众所周知,在喵哈哈村,有一个温柔善良的卿学姐. 卿学姐喜欢和她一 ...