现状:
把filter\SetCharacterEncodingFilter.class放在web-inf\classes目录
在web.xml中添加
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
后,启动tomcat5.0.28,出现
2007-3-13 17:43:46 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2007-3-13 17:43:46 org.apache.catalina.core.StandardContext start
严重: Context startup failed due to previous errors
解决办法:
c:\> cd 主页目录\web-inf\classes
c:\> jar cvf filters.jar filters
形成filters.jar文件,把它放在 tomcat\common\lib下,重新启动tomcat,问题解决!