<listener>
<listener-class>config</listener-class>
</listener>
<servlet>
<servlet-name>ProcessReg</servlet-name>
<servlet-class>ProcessReg</servlet-class>
<init-param>
<param-name>text</param-name>
<param-value>HelloWorld1</param-value>
</init-param>
public class config implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent event) {
ServletContext servletContext = event.getServletContext();
String text1 = servletContext.getInitParameter("text");
在方法 contextInitialized(ServletContextEvent event)
中,如果有两个 servlet,例如,假设第二个 servlet 的名称是Servlet2
,假设 has 也init - param
调用text
了 value HelloWorld2
。
怎么listener
知道带ProcessReg
servlet?
如何param
从Servlet2
??