开发者

How can I pass init parameters to HttpSessionListener?

When configuring filters, I can pass some values to a filter as initial parameters in web.xml and obtain those values in Filter via FilterConfig. How can I开发者_如何学Go configure some initial parameters in web.xml for HttpSessionListener? If this is not possible, what are alternatives?


In the code:

public class MyListener implements HttpSessionListener {

   public void sessionCreated(HttpSessionEvent event) {
      String value = event.getSession().getServletContext().getInitParameter(paramName);
   }
}

And in web.xml:

<web-app ...>
...
    <context-param>
        <param-name>my_param</param-name>
        <param-value>12345</param-value>
    </context-param>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜