Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value
出现这个错误 是因为使用了 ObjectMapper来转换json字符串,
请尊重知识,请尊重原创 更多资料参考请见 http://www.cezuwang.com/listFilm?page=1&areaId=906&filmTypeId=1
解决的办法是 1 避免使用这个类
google 的 Gson gson =new Gson() 就是个替代方案,具体的效率问题不讨论
2 使用 ObjectMapper mapper=new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
3 在传入值的时候,去除回车符 换行符 制表符 等
public static boolean isBlankOrNull(String str){ if(null==str)return true; return str.length()==0; } /** * //去除字符串中空格、换行、制表 * @param str * @param pattern * @param replace * @return */ public static String replaceSpecialtyStr(String str,String pattern,String replace){ if(isBlankOrNull(pattern)) pattern="\\s*|\t|\r|\n"; if(isBlankOrNull(replace)) replace=""; return Pattern.compile(pattern).matcher(str).replaceAll(replace); }