今天要用bootstrap开发一个网页,要使用到JSON,但是JSON的格式不正确,然后在http://www.bejson.com/[Be JSON]中测试了一下JSON. 发现JSON中多了一个换行符,然后在输入库中清掉换行符就得到正确的JSON格式了.在Windows或者是SQL中的换行符都是以\r\n存在的,所有使用 Replace()函数置换就行.在Ascii码中,\n是10,\r是13 Update Table Set Column1=Replare(Column1,),'') Up
import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author lei * 2011-9-2 */ public class StringUtils { public static String replaceBlank(String str) { String dest = ""; if (str!=null) { Pattern p = Pattern.compile("\\s*|