&lt;servlet-name&gt;<filter-mapping>里面web.xml,这是什么意思? [英] &lt;servlet-name&gt; inside &lt;filter-mapping&gt; of web.xml, what does this mean?

查看:74
本文介绍了&lt;servlet-name&gt;<filter-mapping>里面web.xml,这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习 Struts 2.我偶然发现了这段代码:

I am starting to learn Struts 2. I stumbled upon this code:

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>


为什么将 servlet 映射到 标签内?这种映射意味着什么?另外, 有什么作用?感谢您的回复.


Why is it a servlet being mapped inside a <filter-mapping> tag? What does this kind of mapping imply? Also, what does <listener> do? Thanks for the replies.

推荐答案

你试过谷歌吗?

为什么将 servlet 映射到标签内?这种有什么作用映射意味着?

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

做什么?

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

这篇关于&lt;servlet-name&gt;<filter-mapping>里面web.xml,这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆