您的位置:首页 > 数据库

SqlException: 将截断字符串或二进制数据

2006-10-24 12:21 375 查看
转载自:http://blog.csdn.net/prostore/article/details/4205183受益匪浅
接下来将要写一个jsonList.JSP页面来将结果承现给用户Html代码

<%@ page language="java" contentType="text/html;charset=UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>json 返回列表处理</title>

<script language="javascript">

var xmlHttp = false;

try{

xmlHttp = new ActiveXObject("msxml2.XMLHTTP");

}catch(e1){

try{

xmlHttp = new ActiveXObject("microsoft.XMLHTTP");

}catch(e2){

try{

xmlHttp = new XMLHttpRequest();

}catch(e3){

xmlHttp = false;

}

}

}

if(!xmlHttp){

alert("create xmlHttpRequest fail");

}

function jsonListResult(){

xmlHttp.onreadystatechange = function(){

if(xmlHttp.readyState == 4) {

var userList = eval('(' + xmlHttp.responseText + ')');

var user = eval(userList.JSONRESULT);

var result = "<table border=0>";

result += "<tr><td>userId</td><td>userName</td><td>sex</td></tr>";

for(var i=0;i<user.length;i++) {

result += "<tr>";

result += "<td>"+user[i].userId +"</td>";

result += "<td>"+user[i].userName+"</td>";

result += "<td>"+user[i].sex+"</td>";

result += "</tr>";

}

result += "</table>";

document.getElementById('jsonDiv').innerHTML = result;

}

}

xmlHttp.open("POST","jsonlist.action",true);

xmlHttp.send(null);

}

</script>

</head>

<body>

<div id="jsonDiv"></div>

<input type="button" value="show list" onclick="jsonListResult();">

</body>

</html>

[html] view plaincopy<%@ page language="java" contentType="text/html;charset=UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>json 返回列表处理</title>

<script language="javascript">

var xmlHttp = false;

try{

xmlHttp = new ActiveXObject("msxml2.XMLHTTP");

}catch(e1){

try{

xmlHttp = new ActiveXObject("microsoft.XMLHTTP");

}catch(e2){

try{

xmlHttp = new XMLHttpRequest();

}catch(e3){

xmlHttp = false;

}

}

}

if(!xmlHttp){

alert("create xmlHttpRequest fail");

}

function jsonListResult(){

xmlHttp.onreadystatechange = function(){

if(xmlHttp.readyState == 4) {

var userList = eval('(' + xmlHttp.responseText + ')');

var user = eval(userList.JSONRESULT);

var result = "<table border=0>";

result += "<tr><td>userId</td><td>userName</td><td>sex</td></tr>";

for(var i=0;i<user.length;i++) {

result += "<tr>";

result += "<td>"+user[i].userId +"</td>";

result += "<td>"+user[i].userName+"</td>";

result += "<td>"+user[i].sex+"</td>";

result += "</tr>";

}

result += "</table>";

document.getElementById('jsonDiv').innerHTML = result;

}

}

xmlHttp.open("POST","jsonlist.action",true);

xmlHttp.send(null);

}

</script>

</head>

<body>

<div id="jsonDiv"></div>

<input type="button" value="show list" onclick="jsonListResult();">

</body>

</html>

转自:http://ctojxzsycztao.javaeye.com/blog/390949
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: