replaceAll( String regex, String replacement) 第一个参数是正则表达式。 看下面代码 template = template.replaceAll("[", "").replaceAll("]", ""); \\报错 template = template.replaceAll("\\[", "").replaceAll("\\]", "");\\ok