还是老问题,一直没有得到回答:
如何:写一个 jsp 或 bean,修改 tomcat 的 tomcat-users.xml 里的用户密码。
升双星啦,给弟兄们表示表示。答对的赠50分,其它人按跟贴顺序赠5分,赠完为止。共发 3 贴,600分。
另外两贴:
http://community.csdn.net/Expert/topic/4872/4872289.xml?temp=.3835413
http://community.csdn.net/Expert/topic/4872/4872295.xml?temp=.2579309
如何:写一个 jsp 或 bean,修改 tomcat 的 tomcat-users.xml 里的用户密码。
升双星啦,给弟兄们表示表示。答对的赠50分,其它人按跟贴顺序赠5分,赠完为止。共发 3 贴,600分。
另外两贴:
http://community.csdn.net/Expert/topic/4872/4872289.xml?temp=.3835413
http://community.csdn.net/Expert/topic/4872/4872295.xml?temp=.2579309
Document myDocument = sb.build("tomcat-users.xml");
Element root = myDocument.getRootElement();
XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
root.setAttribute("comment","introduce myself");
List eleList = root.getChildren("user");
Iterator it = eleList.iterator();
while(it.hasNext()){
Element ele = (Element) it.next();
if(args[0].equals(ele.getAttributeValue("username"))){
ele.setAttribute("password",args[1]);
}
}
xmlOut.output(myDocument,System.out); 好像没改到XML文件里面,不知道最后还要怎么保存更改的数据XMLBEANS 里面确是可以更改,不过还要把XML生成Schema文件
http://www.matrix.org.cn/resource/article/44/44027_XMLBean.html
step 2:xml操作 通过XSLT方法或XmlDocument修改后写回去。
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
……