解决办法2:
传递前,先做以下替换
sContent=sContent.replaceAll(" ","%20");
接收到字符串之后,如果在td中显示,则需要使用
sContent=sContent.replaceAll(" "," ");//注意这里不是替换%20,而是替换空格。如果有中文,要先转码
如果在textarea中显示,则不需要处理。
这样就没问题了。
二、回车换行问题
问题描述:
表单中的textArea中有换行的内容,提交之后保存到数据库,再读取出来的时候,没有换行,全部连在一起了。
解决:
1. 在写入数据库的时候,加入
sContent=sContent.replaceAll(" "," ");
sContent=sContent.replaceAll("/r/n","<br/>");
sContent=sContent.replaceAll("/n","<br/>");
2.在读取的时候,如果要在textArea中显示,需要加入
sc = 数据库中的content字段值 ;
sc=sc.replaceAll("<br/>","/r/n");
sc=sc.replaceAll("<br>","/r/n");
sc=sc.replaceAll(" "," ");
如果是直接在td中显示,则不需要转换 。