xml 文件 放在 web-inf下的 classes目录下
private static String webInfoPath = "config.xml";
/**
* 保存XML文档
*
* @param doc
* @throws IOException
*/
public static void saveDocument(Document doc) throws IOException {
OutputFormat format = OutputFormat.createPrettyPrint();
URL url = Thread.currentThread().getContextClassLoader().getResource(webInfoPath);
XMLWriter writer = new XMLWriter(
new FileOutputStream(url.getFile()), format);
writer.write(doc);
writer.close();
}