后台封装的easyui框架,处理texbox的时候报错:未结束的字符串常量。

原因:特殊字符导致json字符串转换成json对象出错

解决:找到初始值的地方进行过滤

代码如下:

           theString = theString.Replace(">", ">");  

           theString = theString.Replace("<", "&lt;");  

           theString = theString.Replace(" ", "&nbsp;");  

           theString = theString.Replace("\"", "&quot;");  

           theString = theString.Replace("\'", "&#39;");  

           theString = theString.Replace("\\", "\\\\");//对斜线的转义  

           theString = theString.Replace("\n", "\\n");  

           theString = theString.Replace("\r", "\\r");  

 

posted @ 2017-02-23 16:30  haishu  阅读(366)  评论(0编辑  收藏  举报