我在jsp中拼凑json格式的一些htmlstring .有些可以传过去.有些不可以.不明白.我有试string1可以传过去.string2传不过去.,说网页发生错误.望明白的大师能指点致电.
我的
string1里面的html代码是; 
<html xmlns:user="anything here" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {TEXT-ALIGN: center;}
#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; } 
.specials{ font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold; text-align:left}
.apply{ font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left}
</style>
</head>
<body topmargin="0">
<div id="center" style="width:420px;">
<div>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="middle" height="40" bgcolor="#f3f3f3" width="420" style="font-family:Arial, Helvetica, sans-serif; font-size:20px;" align="center">Avanda MP4 N181 Digital Player</td>
</tr>
</table>
</div>
<div style="font-family:Arial, Helvetica, sans-serif; font-size:14px; text-align:left; margin-left:65px; margin-top:7px; margin-bottom:18px; font-weight: 500;">Item: NO.A455-1028</div>
<div style="margin-left:65px; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height:25px;">
<div style="float:left">Our Price:</div>
<div style="float:left; margin-left:23px;  color:#d90000; font-weight:bold; letter-spacing:1.2px;">$110.98</div>
<br>
<div style="float:left">List Price:</div>
<div style="float:left; margin-left:26px; font-weight:bold; color:#222222; letter-spacing:1.2px;">$120.98</div>
<br>
<div style="float:left">Your Save:</div>
<div style="float:left; margin-left:23px; font-weight:bold; color:#222222; letter-spacing:1.2px;">$10.00</div>
<br>
<div style="float:left; margin-top:15px;">Quantity:</div>
<div style="float:left; margin-left:30px; margin-top:15px;">
<select><option value="first" selected="selected">1</option><option>2</option><option>3</option><option>4</option></select>
</div>
<div style="clear:both">
<div style="float:left; margin-top:5px;">Grade:</div>
<div style="float:left; margin-left:23px; margin-top:10px;">
<img src="images/4-stars.gif"></div>
</div>
<div style="clear:both; text-align:left">
<img src="images/Unigroup-web-design-product.2.7_16.gif"></div>
</div>
</div>
</body>
</html>
string2里面的html代码是:
<html xmlns:user="anything here" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {TEXT-ALIGN: center;}
#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; } 
.specials{ font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; text-align:left}
.apply{ font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;}
</style>
</head>
<body topmargin="0">
<div id="center" style="width:420px;">
<div class="specials" style="font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold; text-align:left">
  Specials
  <hr>
</div>
<div class="apply" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left">
  Apply now and if you're approved instantly, save 30$ off your<br>
  Purchase, earn 3% rewards
  </div>
<div style="float:left; margin-left:20px; margin-top:15px;">
<img src="images/Unigroup-web-design-product.2.7_13.gif" width="80"></div>
<div style="float:left; margin-left:60px; margin-top:20px; line-height:19px;" class="apply">
<div style="float:left;  font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;">Original Price: </div>
<font color="#858585">
<div style="float:left; margin-left:15px;  font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;">$30.00</div>
</font>
<br>
<div style="float:left;  font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;">Discount: </div>
<font color="#4953a0">
<div style="float:left; margin-left:37px;  font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;">-$13.28</div>
</font>
<br>
<b>
<div style="float:left;  font-family:Arial, Helvetica, sans-serif; font-size:13px; text-align:left; line-height:19px;"> Combo Price: </div>
<div style="float:left; margin-left:25px;  font-family:Arial, Helvetica, sans-serif; font-size:14px; text-align:left; line-height:19px; letter-spacing:1.2px;">
<font color="#e13333">$16.72</font>
</div>
</b>
</div>
<div style="clear:both; margin-top:5px; margin-left:30px;">
<div style="float:left">
<img src="images/Unigroup-web-design-product.2.7_28.gif"></div>
<div style="float:left">
<img src="images/Unigroup-web-design-product.2.7_29.gif"></div>
</div>
<div style="clear:both; margin-left:30px;">
<div style="float:left">
<img src="images/Unigroup-web-design-product.2.7_31.gif"></div>
<div style="float:left">
<img src="images/Unigroup-web-design-product.2.7_32.gif"></div>
</div>
</div>
</body>
</html>上面的htmlstring我的jsp都会显示出来.就是通过ajax传到前台去.前者是成功的.后者却是网页发生错误.

解决方案 »

  1.   

    {'lastBuildDate':'lastBuildDate','chill':'ffffgg','direction':' Avanda MP4 N181 Digital Player Item: NO.A455-1028
    Our Price:$110.98
    List Price:$120.98
    Your Save:$10.00
    Quantity:1234Grade:','speed':'html1','humidity':'fggfgf','visibility':'jkkjkj','sunrise':'fgfsgf','sunset':'extras','condition':'product_spec','temp':'fgsgzzz','low':'rrrrr','high':'zffggfgf'}
    这个json是可以传过去.但是
    {'lastBuildDate':'lastBuildDate','chill':'ffffgg','direction':' Specials 
    --------------------------------------------------------------------------------Apply now and if you're approved instantly, save 30$ off your
    Purchase, earn 3% rewards 
    Original Price: $30.00
    Discount: -$13.28
    Combo Price: $16.72','speed':'html1','humidity':'fggfgf','visibility':'jkkjkj','sunrise':'fgfsgf','sunset':'extras','condition':'product_spec','temp':'fgsgzzz','low':'rrrrr','high':'zffggfgf'}
    这个json传不过去.这是第二个网页发生错误.也没有说错误是什么啊.jsp是可以打印出上面的那些东西的.上面两个json 我是从jsp页面上复制下来的.
      

  2.   

    direct 后面的数据其实是htmlstring .我从浏览器上面复制下来有些没有显示.
      

  3.   

    经过研究:研究不能发送过去的htmlstring代码,是因为不能被传送过去的htmlstring里面我有这样的字符you'are
    里面的"'",我把you'are 换成you are就可以了.两个不能发送的htmlstring都是这样的原因.另外一个是因为I've
    里面的"'".把"'"删了也是ok的了.恩.分享下:象这种特殊字符在语言里是有特别的含义的.解析的时候会发生错误..
    请大家注意.
      

  4.   

    恩.那个json的java包昨天已经下了.之前试的时候还没有配置上去.那个东西确实会自动转换在配置了json包后.tks