服务的配置文件是自己解析@feilong
是自已解析的,代码如下:
public class ReadService {
public String readService(String value) {
String fileName = "/service.xml";
String classname = "";
try {
ReadXML readXmlBean = new ReadXML();
String file = java.net.URLDecoder.decode(this.getClass().getResource(fileName).toString(), "UTF-8");
file = file.substring(file.indexOf(":") + 1, file.length());
readXmlBean.readXML(file);//读取指定路径的XML文件
Document doc = readXmlBean.getXmlDoc();
Element root = doc.getRootElement();
java.util.List lsTable = root.getChildren();//得到根节点下的所有子节点
for (Iterator iterTable = lsTable.iterator(); iterTable.hasNext(); ) {
Element elTable = (Element) iterTable.next();
if (value.equals(elTable.getAttributeValue("name"))){
classname = elTable.getAttributeValue("class");
break;
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return classname;
}
回复 更多评论