dom4j selectSingleNode方法返回为null

kingwang2012 kingwang2012 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面一段代码用于取出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,不知道为什么
...全文
评论 8
收藏 已收藏
分享
返回顶部
kingwang2012
Web 开发 81,107 成员 341,720 内容