我开始学习 Struts 2。我偶然发现了这段代码:
web.xml
...some other codes...
<filter>
<filter-name>MyFilter</filter-name>
<display-name>MyFilter</display-name>
<filter-class>com.xxx.yyy.zzz.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<servlet-name>MyAction</servlet-name>
</filter-mapping>
<listener>
<listener-class>com.xxx.yyy.StrutsListener</listener-class>
</listener>
<servlet>
<servlet-name>MyAction</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>paramName1param-name>
<param-value>paramVal1</param-value>
</init-param>
<init-param>
<param-name>paramName2</param-name>
<param-value>paramVal2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
...some other codes...
我的问题在这部分
<filter-mapping>
<filter-name>MyFilter</filter-name>
<servlet-name>MyAction</servlet-name>
</filter-mapping>
为什么在 <filter-mapping>
中映射一个 servlet标签?这种映射意味着什么?另外,<listener>
是什么意思?做?感谢您的回复。
最佳答案
你用过谷歌吗?
Why is it a servlet being mapped inside a tag? What does this kind of mapping imply?
阅读:http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html#1039330
what does
<listener>
do?
http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html#1039300
示例:http://tomcat-configure.blogspot.in/2009/01/tomcat-context-listener-example.html
关于java - web.xml的<filter-mapping>里面的<servlet-name>是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11661792/