在 JSP 文件中使用 Java 编辑 XML 文件时出现并发修改错误。这是如何引起的,我该如何解决?
ElementFilter f = new ElementFilter("rurl-link");
Iterator subchilditr = childNode.getDescendants(f);
while (subchilditr.hasNext()) { // Exception is thrown here.
Element subchild = (Element) subchilditr.next();
if (subchild.getText().equalsIgnoreCase(prevtext)) {
subchild.setText(link);
out.println("Updated");
}
}
这是堆栈跟踪:
java.util.ConcurrentModificationException
java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
java.util.AbstractList$Itr.next(AbstractList.java:343)
org.jdom.DescendantIterator.next(DescendantIterator.java:134)
org.jdom.FilterIterator.hasNext(FilterIterator.java:91)
org.apache.jsp.rurl_005fchangelink_005fxml_jsp._jspService(rurl_005fchangelink_005fxml_jsp.java:101)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)