比如 String temp = "It's a cat"; 如果将temp字符串保存到数据库,需要将单引号(')替换为(\’)。 temp = temp.replaceAll("'", "\\\\'"); 转换后,再作为参数拼入SQL即可