日期:2014-05-16  浏览次数:20377 次

局部刷新JS主要代码
function pinfolists() {
$(document).ready(
function() {
var typeID = document.getElementById("reinfoID").value;
var title = document.getElementById("title").value;
var stime = $('#sTime').datebox('getValue');
var etime = $('#eTime').datebox('getValue');
if (typeID == 0) {
alert("请选择类型");
return;
} else {
$.ajax( {
type : "post",
dataType : "json",
url : "infosManager.do?action=conListMore",
data : {
"reinfoID" : typeID,
"title" : title,
"stime" : stime,
"etime" : etime
},
success : function(data) {
$("#coninfotable").html("");
var widthnumber = [ "45%", "15%", "25%", "15%" ];
var topvalue = [ "标题", "类型", "时间", "操作" ];
var tr = $("<tr>");
for ( var i = 0; i < 4; i++) {
var td = $("<td>")
.attr("width", widthnumber[i]);
tr.append(td.append(topvalue[i]));
}
$("#coninfotable").append(tr);
$.each(data, function(row, obj) {
var r = $("<tr>");
for ( var j = 0; j < 4; j++) {
var t = $("<td>").attr("id", "p" + j);
r.append(t);
r.find("#p0").text(obj.title);
r.find("#p1").text(obj.infoTypeJson.name);
r.find("#p2").text(
dateFormat(new Date(obj.pubTime),
"yyyy-MM-dd hh:mm:ss"));
var ct1=$("<input>").attr("type","hidden").attr("id",obj.id).attr("value",obj.name);
var ct2='<input type="button" value="查看" onclick="showReAllInfos('+obj.id+',\''+obj.title+'\')">';
r.find("#p3").append(ct1);
r.find("#p3").append(ct2);
$("#coninfotable").append(r);
}
r.appendTo("#coninfotable");
 
});
}
});
}
});
 
}
//格式化日期
function dateFormat(x, y) {
var z = {
M : x.getMonth() + 1,
d : x.getDate(),
h : x.getHours(),
m : x.getMinutes(),
s : x.getSeconds()
};
y = y.replace(/(M+|d+|h+|m+|s+)/g, function(v) {
return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2)
});
return y.replace(/(y+)/g, function(v) {
return x.getFullYear().toString().slice(-v.length)
});
}

?

java List转JSON

String json = JSON.toJSONString(conSidPage);

PrintWriter pw = response.getWriter();

response.getWriter().write(json);

pw.flush();

pw.close();

return null;