dom4j selectSingleNode方法返回为null
下面一段代码用于取出web.xml中的session-timeout元素的值,我调用了dom4j的selectSingleNode方法,但是返回的值总是null,请大家帮我看看错在哪里?
public HashMap getSessionTimeOut(String fileName)throws MalformedURLException,
DocumentException
{
HashMap map=new HashMap();
try
{
Document document = read(fileName);
Node node=document.selectSingleNode("//session-timeout");
map.put("session-timeout", node.getText());
}
catch (DocumentException e)
{
System.out.println(e.getMessage());
}
catch (IOException es)
{
System.out.println(es.getMessage());
}
catch(Exception ee)
{
ee.printStackTrace();
}
return map;
}
document 的值肯定不为null,这个我已经跟踪过。我再web.xml中设置了这个元素:
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
每次总说node为null,不知道为什么