严重:Exception starting filter encodingFilter

时间:2021-04-07 18:29:14
Exception starting filter encodingFilter
java.lang.ClassNotFoundException: com.sterning.commons.SetCharacterEncodingFilte
r
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1206)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter
Config.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFil
terConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterCon
fig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:37
09)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1212)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSuppor
t.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:
1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processC
hildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processC
hildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(Cont
ainerBase.java:1590)
at java.lang.Thread.run(Unknown Source)
2008-11-24 21:02:29 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2008-11-24 21:02:29 org.apache.catalina.core.StandardContext start
严重: Context [/newstest] startup failed due to previous errors
2008-11-24 21:02:29 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
INFO - Closing org.springframework.web.context.support.XmlWebApplicationContext@
1d267b5: display name [Root WebApplicationContext]; startup date [Mon Nov 24 21:
02:23 CST 2008]; root of context hierarchy
INFO - Destroying singletons in org.springframework.beans.factory.support.Defaul
tListableBeanFactory@15e2639: defining beans [dataSource,sessionFactory,newsDao,
newsManager,addBean,listBean,deleteBean,transactionManager,txAdvice,org.springfr
amework.aop.config.internalAutoProxyCreator,allManagerMethod,org.springframework
.aop.support.DefaultBeanFactoryPointcutAdvisor]; root of factory hierarchy
INFO - Closing Hibernate SessionFactory
INFO - closing

6 个解决方案

#1


请高手帮助!

#2


类没有找到com.sterning.commons.SetCharacterEncodingFilter
确定你的类名(包括package)没有搞错。
如果错了,在web。xml中修改。

#3


Struts2+Spring2+Hibernate3 的web应用

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- OpenSessionInViewFilter过滤器 -->
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>


<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
com.sterning.commons.SetCharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>


<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<welcome-file-list>
<welcome-file>add.jsp</welcome-file>
</welcome-file-list>
</web-app>

#4


请问com.sterning.commons.SetCharacterEncodingFilter 在哪个包中?

#5


com/sterning/commons这个包咯。
你是不是用了别人的代码 (http://www.blogjava.net/sterning/archive/2007/10/08/151057.html)
你都可以先把这个filter注释掉。 
Spring有一个类似的filter,

<filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>  

#6


谢谢,修改成:
 <filter> 
        <filter-name>encodingFilter </filter-name> 
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter </filter-class> 
        <init-param> 
            <param-name>encoding </param-name> 
            <param-value>UTF-8 </param-value> 
        </init-param> 
        <init-param> 
            <param-name>forceEncoding </param-name> 
            <param-value>true </param-value> 
        </init-param> 
    </filter>  
就解决了,

#1


请高手帮助!

#2


类没有找到com.sterning.commons.SetCharacterEncodingFilter
确定你的类名(包括package)没有搞错。
如果错了,在web。xml中修改。

#3


Struts2+Spring2+Hibernate3 的web应用

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- OpenSessionInViewFilter过滤器 -->
<filter>
<filter-name>lazyLoadingFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>


<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
com.sterning.commons.SetCharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>


<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>lazyLoadingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


<welcome-file-list>
<welcome-file>add.jsp</welcome-file>
</welcome-file-list>
</web-app>

#4


请问com.sterning.commons.SetCharacterEncodingFilter 在哪个包中?

#5


com/sterning/commons这个包咯。
你是不是用了别人的代码 (http://www.blogjava.net/sterning/archive/2007/10/08/151057.html)
你都可以先把这个filter注释掉。 
Spring有一个类似的filter,

<filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>  

#6


谢谢,修改成:
 <filter> 
        <filter-name>encodingFilter </filter-name> 
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter </filter-class> 
        <init-param> 
            <param-name>encoding </param-name> 
            <param-value>UTF-8 </param-value> 
        </init-param> 
        <init-param> 
            <param-name>forceEncoding </param-name> 
            <param-value>true </param-value> 
        </init-param> 
    </filter>  
就解决了,