我使用這個正則表達式我是一個簡單的方法主要測試了它從我的字符串SVG .replaceAll("\\{", "{")
刪除所有逃生符號的所有逃生的符號,當我試圖把它工作正常取下字符串SVG JAVA
System.out.println("<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" class=\"highcharts-root\" style=\"font-family:"lucida grande", "lucida sans unicode", arial, helvetica, sans-serif;font-size:12px;\" xmlns=\"http://www.w3.org/2000/svg\" width=\"600\" height=\"350\"><desc>Created"
+ " with Highcharts 5.0.7</desc><defs><clipPath id=\"highcharts-lqrco8y-45\"><rect x=\"0\" y=\"0\" width=\"580\" height=".replaceAll("\\{", "{"));
在我的代碼中使用這個沒有例外,但替換所有函數似乎沒有工作。
@RequestMapping(value = URL, method = RequestMethod.POST)
public String svg(@RequestBody String svg) throws TranscoderException, IOException {
String result = svg;
String passStr = (String) result.subSequence(5, result.length() - 2);
passStr = passStr.replaceAll("\\{", "{");
InputStream is = new ByteArrayInputStream(Charset.forName("UTF-8").encode(passStr).array());
service.converter(is);
return result;
}
如果要解析XML,請使用XML解析器。 –