日期:2014-05-20  浏览次数:21079 次

web.xml导致的tomcat服务器错误,望高手指点
在<tomcat安装目录>\webapps中创建了一个filter目录。
并创建filter\WEB-INF\web.xml文件,内容如下:
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5">
   
  <filter>
  <filter-name>FirstFilter</filter-name>
  <filter-class>FirstFilter</filter-class>
  <init-param>
  <param-name>encoding</param-name>
  <param-value>GB2312</param-value>
  </init-param>
  </filter>
   
  <filter-mapping>
  <filter-name>FirstFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
   
  <filter-mapping>
  <filter-name>FirstFilter</filter-name>
  <servlet-name>default</servlet-name>
  </filter-mapping>
   
  <filter-mapping>
  <filter-name>FirstFilter</filter-name>
  <url-pattern>/test.html</url-pattern>
  </filter-mapping>

</web-app>

重启 tomcat服务器,tomcat服务器命令行窗口出现如下错误:
2009-2-14 23:09:49 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2009-2-14 23:09:49 org.apache.catalina.core.StandardContext start
严重: Context [/filter] startup failed due to previous errors

请高手指点一下这是什么原因?
该如何解决?

------解决方案--------------------
你的 <filter-mapping> 多了两个改一下:
XML code

<?xml version="1.0" encoding="ISO-8859-1"?> 

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    version="2.5"> 
    
    <filter> 
        <filter-name>FirstFilter </filter-name> 
        <filter-class>FirstFilter </filter-class> 
        <init-param> 
            <param-name>encoding </param-name> 
            <param-value>GB2312 </param-value> 
        </init-param> 
    </filter> 
    
    <filter-mapping> 
        <filter-name>FirstFilter </filter-name> 
        <url-pattern>/* </url-pattern> 
    </filter-mapping> 
</web-app>