【发布时间】:2010-10-21 09:29:19
【问题描述】:
我一直在尝试从here修改JSP中的以下代码:
ArrayList arrayList=new ArrayList();
String = "tagToFind";
Node n = node.getParentNode();
String printOut = "";
while (n != null && !n.getNodeName().equals(tagToFind)) {
n = n.getParentNode();
}
if (n.getNodeValue() != null){
arrayList.add(n.getNodeValue());
}
在“if (n.getNodeValue() != null){”行我收到“NullPointerException”错误。我不明白为什么我在尝试测试 Null 并跳过它们时收到该错误。
谁能帮我解决这个问题?
【问题讨论】: