如何从web.xml文件中读取session-timeout?
已尝试
getServletContext().getAttribute("session-timeout").toString(); 但却给了我NullPointerException。
也尝试过
getServletConfig().getInitParameter("session-timeout");但是给了我null,因为很明显这不是一个init-param
发布于 2013-07-08 22:37:11
这里有一个眼线笔。
int sessionTimeoutFromWebXml = Integer.parseInt(XPathFactory.newInstance().newXPath().compile("web-app/session-config/session-timeout").evaluate(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(getServletContext().getResourceAsStream("/WEB-INF/web.xml"))));;)
发布于 2013-07-08 22:09:17
它应该是
session.getMaxInactiveInterval();它将以秒为单位返回时间。
https://stackoverflow.com/questions/17528373
复制相似问题