JSF中沒有配置監聽器為什麼ConfigureListener還是能被呼叫呢

ppm10103發表於2006-05-18
JSF1.1的sun實現的guessNumber的例子

web.xml程式碼:


<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app>

<display-name>JavaServer Faces Guess Number Sample Application</display-name>
<description>
JavaServer Faces Guess Number Sample Application
</description>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default
value is false.
</description>
</context-param>

<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to verify that all of the application
objects you have configured (components, converters,
renderers, and validators) can be successfully created.
Default value is false.
</description>
</context-param>

<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>


<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/guess/*</url-pattern>
</servlet-mapping>

<security-constraint>
<!-- This security constraint illustrates how JSP pages
with JavaServer Faces components can be protected from
being accessed without going through the Faces Servlet.
The security constraint ensures that the Faces Servlet will
be used or the pages will not be processed. -->
<display-name>Restrict access to JSP pages</display-name>
<web-resource-collection>
<web-resource-name>
Restrict access to JSP pages
</web-resource-name>
<url-pattern>/greeting.jsp</url-pattern>
<url-pattern>/response.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>
With no roles defined, no access granted
</description>
</auth-constraint>
</security-constraint>

</web-app>

上面並沒有配置監聽器,但是看看下面的內容

Thread: main
<init>() : 98, com.sun.faces.application.ApplicationAssociate, ApplicationAssociate.java
<init>() : 98, com.sun.faces.application.ApplicationImpl, ApplicationImpl.java
getApplication() : 74, com.sun.faces.application.ApplicationFactoryImpl, ApplicationFactoryImpl.java
application() : 384, com.sun.faces.config.ConfigureListener, ConfigureListener.java
configure() : 427, com.sun.faces.config.ConfigureListener, ConfigureListener.java
configure() : 402, com.sun.faces.config.ConfigureListener, ConfigureListener.java
contextInitialized() : 332, com.sun.faces.config.ConfigureListener, ConfigureListener.java ---------是一個監聽器
listenerStart() : 3669, org.apache.catalina.core.StandardContext, StandardContext.java
start() : 4104, org.apache.catalina.core.StandardContext, StandardContext.java
start() : 1012, org.apache.catalina.core.ContainerBase, ContainerBase.java
start() : 718, org.apache.catalina.core.StandardHost, StandardHost.java
start() : 1012, org.apache.catalina.core.ContainerBase, ContainerBase.java
start() : 442, org.apache.catalina.core.StandardEngine, StandardEngine.java
start() : 450, org.apache.catalina.core.StandardService, StandardService.java
start() : 683, org.apache.catalina.core.StandardServer, StandardServer.java
start() : 537, org.apache.catalina.startup.Catalina, Catalina.java
invoke0() : -1, sun.reflect.NativeMethodAccessorImpl, NativeMethodAccessorImpl.java
invoke() : 39, sun.reflect.NativeMethodAccessorImpl, NativeMethodAccessorImpl.java
invoke() : 25, sun.reflect.DelegatingMethodAccessorImpl, DelegatingMethodAccessorImpl.java
invoke() : 585, java.lang.reflect.Method, Method.java
start() : 271, org.apache.catalina.startup.Bootstrap, Bootstrap.java
main() : 409, org.apache.catalina.startup.Bootstrap, Bootstrap.java

這個web.xml沒有配置監聽器為什麼監聽器ConfigureListener還是能被呼叫呢?

相關文章