开发者

How to access a configuration element from jboss-web.xml?

开发者 https://www.devze.com 2023-01-26 18:50 出处:网络
I need to access the virtual-host element, but开发者_开发问答 I don\'t know how to access the contents of this file programatically.Fire up your favourite programming language that understands XML and

I need to access the virtual-host element, but开发者_开发问答 I don't know how to access the contents of this file programatically.


Fire up your favourite programming language that understands XML and parse the server.xml file. Use XPath to locate the element you're interested in and change it. Then write the server.xml file back out again.

If you're into Java and DOM then something like this would get you started:

DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new InputSource(new FileReader("/path/to/your/server.xml")));
// And start exploring the NodeList...
NodeList nodeList = document.getFirstChild().getChildNodes();
0

精彩评论

暂无评论...
验证码 换一张
取 消