配置过滤器时,我可以将一些值作为web.xml中的初始参数传递给过滤器,并通过FilterConfig在Filter中获取这些值.如何在web.xml中为HttpSessionListener配置一些初始参数?如果不可能,有什么替代方案?
在代码中:
public class MyListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent event) {
String value = event.getSession().getServletContext().getInitParameter(paramName);
}
}
Run Code Online (Sandbox Code Playgroud)
在web.xml中:
<web-app ...>
...
<context-param>
<param-name>my_param</param-name>
<param-value>12345</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2489 次 |
| 最近记录: |