WEB-INF目录下有applicationContext.xml?

解决方案 »

  1.   

    applicationContext.xml文件没被找到
    你截下项目文件结构图,以及加载applicationContext.xml的web.xml的内容发出来一下
      

  2.   

    <?xml version="1.0" encoding="UTF-8"?>
    <beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    ">


    <!-- 自动扫描与装配bean -->
    <context:component-scan base-package="cn.itcast.oa"></context:component-scan>



    <!-- 数据连接池配置 -->
    <!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">-->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
    <property name="user" value="itcate"/>
    <property name="password" value="itcate"/>


    <!-- =========== 连接池的管理配置 =========== -->
    <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
    <property name="initialPoolSize" value="3"></property>
    <!--连接池中保留的最小连接数。Default: 3 -->
    <property name="minPoolSize" value="3"></property>
    <!--连接池中保留的最大连接数。Default: 15 -->
    <property name="maxPoolSize" value="5"></property>
    <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
    <property name="acquireIncrement" value="3"></property>
    <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->
    <property name="maxStatements" value="8"></property>
    <!--maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->
    <property name="maxStatementsPerConnection" value="5"></property>
    <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
    <property name="maxIdleTime" value="1800"></property>

    </bean>


    <!-- 配置SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource"><ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.Oracle9Dialect
    </prop>
    </props>
    </property>
    </bean>
     

    <!-- 配置声明式的事务管理 (采用注解方式)-->
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>

    </beans>
      

  3.   

    <?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">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <filter>
       <filter-name>struts2</filter-name>
       <filter-class>
       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
       </filter-class>
      </filter>
       <!-- spring监听器 -->
       <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>
      <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>*.action</url-pattern>
      </filter-mapping>
        <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      </web-app>
      

  4.   

        <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>改成<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/WEB-INF/applicationContext.xml</param-value>
      </context-param>
      

  5.   

    <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:/WEB-INF/applicationContext.xml</param-value>
      </context-param>
      

  6.   

    先改成这样,试试
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/WEB-INF/applicationContext.xml</param-value>
      </context-param>