struts2+spring+hibernate整合的问题

时间:2021-01-01 08:22:25
3-17 13:02:40.125 : INFO [main] Root WebApplicationContext: initialization started
03-17 13:02:40.171 : INFO [main] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@e0cc23: display name [Root WebApplicationContext]; startup date [Tue Mar 17 13:02:40 CST 2009]; root of context hierarchy
03-17 13:02:40.234 : INFO [main] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
03-17 13:02:40.390 : INFO [main] Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@e0cc23]: org.springframework.beans.factory.support.DefaultListableBeanFactory@29ce8c
03-17 13:02:40.437 : INFO [main] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29ce8c: defining beans [dataSource,sessionFactory,usersDao,usersManager]; root of factory hierarchy
03-17 13:02:40.468 : INFO [main] MLog clients using log4j logging.
03-17 13:02:40.593 : INFO [main] Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]
03-17 13:02:40.718 : INFO [main] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29ce8c: defining beans [dataSource,sessionFactory,usersDao,usersManager]; root of factory hierarchy
03-17 13:02:40.734 : ERROR [main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 40 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.class$(LocalSessionFactoryBean.java:174)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:174)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
... 42 more

16 个解决方案

#1


03-17 13:02:40.734 : ERROR [main] Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 

#2


antlr-2.7.6.jar,asm-2.2.3.jar,aspectjrt.jar,aspectjweaver.jar,c3p0-0.9.1.jar,cglib-nodep-2.1_3.jar,commons-collections.jar,commons-lang.jar,commons-logging-1.0.4.jar,commons-validator.jar,dom4j-1.6.1.jar,hibernate3.jar,jta.jar,log4j-1.2.15.jar,mysql-connector-java-5.0.7-bin.jar,ognl-2.6.11.jar,spring.jar,struts2-core-2.1.6.jar,struts2-spring-plugin-2.1.6.jar,xwork-2.1.2.jar已经加入了如上类包还是不行。

#3


配置文件写错了吧

#4


org/slf4j/LoggerFactory 这个类找不到,你是不是jar包少了

#5


<?xml version="1.0" encoding="GBK"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/wscm"/>
<!-- 指定连接数据库的用户名 -->
<property name="user" value="wscm"/>
<!-- 指定连接数据库的密码 -->
<property name="password" value="wscm10011"/>
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="20"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
    <!--定义了Hibernate的SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
            <list>
<value>com/wscm/model/main/Users.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.jdbc.batch_size">20</prop> 
            </props>
        </property>
    </bean> 
    <bean id="usersDao" class="com.wscm.dao.main.UsersDaoImp">
     <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="usersManager" class="com.wscm.service.main.UsersManagerImp">
        <property name="usersDao" ref="usersDao"/>
    </bean>
</beans>





这是配置文件应该没错吧


<?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">
 <!-- spring的应用上下文 -->
 <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>
  <!--  设置字符编码-->  
   <filter>
     <filter-name>Set Character Encoding</filter-name>
     <filter-class>com.wscm.common.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>
   <!--  定义struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
   <!--  随机验证码 -->
    <servlet>
        <servlet-name>img</servlet-name>
        <servlet-class>com.wscm.common.AuthImg</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>img</servlet-name>
    <url-pattern>/authImg</url-pattern>
    </servlet-mapping>
<!-- 首页面设置 -->
 
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

#6


  jar包的问题....
    我整合过比较精简的.jar包
想要可以加我QQ给你一份:176468750

#7


有遇到过这个问题的吗

#8


java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 


没有加 slf4j的jar包

#9


添加了slf4j的jar包同样出现如下的错误
03-17 14:09:04.343 : ERROR [main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter

#10


引用 9 楼 jncharles 的回复:
添加了slf4j的jar包同样出现如下的错误
03-17 14:09:04.343 : ERROR [main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter


你的jar包还是少了啊

#11


是少了哪一个,有知道的吗

#12


以上的问题已经解决了。但是又出现了如下的错误
org.apache.catalina.core.standardcontext start 
error filterstart

#13


在struts。xml的配置文件里 
<constant name="struts.devMode" value="false" />    
看看还是这个问题 value

#14


楼上的做法也不行

#15


下面是我的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">
 <!-- spring的应用上下文 -->
 <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>
  <!--  设置字符编码-->  
   <filter>
     <filter-name>Set Character Encoding</filter-name>
     <filter-class>com.wscm.common.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>
   <!--  定义struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
   <!--  随机验证码 -->
    <servlet>
        <servlet-name>img</servlet-name>
        <servlet-class>com.wscm.common.AuthImg</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>img</servlet-name>
    <url-pattern>/authImg</url-pattern>
    </servlet-mapping>
<!-- 首页面设置 -->
 
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

#16


问题全部得以解决,谢谢大家的讨论。

#1


03-17 13:02:40.734 : ERROR [main] Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 

#2


antlr-2.7.6.jar,asm-2.2.3.jar,aspectjrt.jar,aspectjweaver.jar,c3p0-0.9.1.jar,cglib-nodep-2.1_3.jar,commons-collections.jar,commons-lang.jar,commons-logging-1.0.4.jar,commons-validator.jar,dom4j-1.6.1.jar,hibernate3.jar,jta.jar,log4j-1.2.15.jar,mysql-connector-java-5.0.7-bin.jar,ognl-2.6.11.jar,spring.jar,struts2-core-2.1.6.jar,struts2-spring-plugin-2.1.6.jar,xwork-2.1.2.jar已经加入了如上类包还是不行。

#3


配置文件写错了吧

#4


org/slf4j/LoggerFactory 这个类找不到,你是不是jar包少了

#5


<?xml version="1.0" encoding="GBK"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/wscm"/>
<!-- 指定连接数据库的用户名 -->
<property name="user" value="wscm"/>
<!-- 指定连接数据库的密码 -->
<property name="password" value="wscm10011"/>
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="20"/>
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1"/>
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1"/>
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20"/>
</bean>
    <!--定义了Hibernate的SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mappingResources">
            <list>
<value>com/wscm/model/main/Users.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.jdbc.batch_size">20</prop> 
            </props>
        </property>
    </bean> 
    <bean id="usersDao" class="com.wscm.dao.main.UsersDaoImp">
     <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="usersManager" class="com.wscm.service.main.UsersManagerImp">
        <property name="usersDao" ref="usersDao"/>
    </bean>
</beans>





这是配置文件应该没错吧


<?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">
 <!-- spring的应用上下文 -->
 <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>
  <!--  设置字符编码-->  
   <filter>
     <filter-name>Set Character Encoding</filter-name>
     <filter-class>com.wscm.common.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>
   <!--  定义struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
   <!--  随机验证码 -->
    <servlet>
        <servlet-name>img</servlet-name>
        <servlet-class>com.wscm.common.AuthImg</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>img</servlet-name>
    <url-pattern>/authImg</url-pattern>
    </servlet-mapping>
<!-- 首页面设置 -->
 
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

#6


  jar包的问题....
    我整合过比较精简的.jar包
想要可以加我QQ给你一份:176468750

#7


有遇到过这个问题的吗

#8


java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 


没有加 slf4j的jar包

#9


添加了slf4j的jar包同样出现如下的错误
03-17 14:09:04.343 : ERROR [main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter

#10


引用 9 楼 jncharles 的回复:
添加了slf4j的jar包同样出现如下的错误
03-17 14:09:04.343 : ERROR [main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter


你的jar包还是少了啊

#11


是少了哪一个,有知道的吗

#12


以上的问题已经解决了。但是又出现了如下的错误
org.apache.catalina.core.standardcontext start 
error filterstart

#13


在struts。xml的配置文件里 
<constant name="struts.devMode" value="false" />    
看看还是这个问题 value

#14


楼上的做法也不行

#15


下面是我的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">
 <!-- spring的应用上下文 -->
 <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>
  <!--  设置字符编码-->  
   <filter>
     <filter-name>Set Character Encoding</filter-name>
     <filter-class>com.wscm.common.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>
   <!--  定义struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
   <!--  随机验证码 -->
    <servlet>
        <servlet-name>img</servlet-name>
        <servlet-class>com.wscm.common.AuthImg</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>img</servlet-name>
    <url-pattern>/authImg</url-pattern>
    </servlet-mapping>
<!-- 首页面设置 -->
 
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

#16


问题全部得以解决,谢谢大家的讨论。