這裏是從Spring-WS手冊摘錄如下代碼:JDOM 2和XPath
public class HolidayEndpoint {
private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas";
private XPath startDateExpression;
private XPath endDateExpression;
private XPath nameExpression;
private HumanResourceService humanResourceService;
@Autowired
public HolidayEndpoint(HumanResourceService humanResourceService) (2)
throws JDOMException {
this.humanResourceService = humanResourceService;
Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
startDateExpression = XPath.newInstance("//hr:StartDate");
startDateExpression.addNamespace(namespace);
endDateExpression = XPath.newInstance("//hr:EndDate");
endDateExpression.addNamespace(namespace);
nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
nameExpression.addNamespace(namespace);
}
我的問題是,這似乎使用JDOM 1.0和我想使用JDOM 2.0。
如何將此代碼從JDOM 1.0轉換爲JDOM 2.0?爲什麼不更新他們的示例代碼?
謝謝!
你更新你的進口使用jDom2?例如,元素的導入是'import org.jdom2.Element;'。 – 2013-10-08 15:05:43