我的 applicationContext.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<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.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/test"></property>
<property name="username" value="root"></property>
<property name="password" value="123456"></property>
</bean>
<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.MySQLDialect
</prop>
<prop key="hibernate.connection.autocommit">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/zh/dao/Userinfo.hbm.xml</value>
<value>org/zh/dao/Username.hbm.xml</value></list>
</property></bean>

<bean id="UserinfoDAO" class="org.zh.dao.UserinfoDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="UsernameDAO" class="org.zh.dao.UsernameDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="getinfo" class="org.zh.java.GetInfo">
<property name="userinfoDAO">
<ref bean="UserinfoDAO"/>
</property>
</bean>

<!-- 
<bean id="getinfo" class="org.zh.java.GetInfo">
<property name="iuserinfoDAO">
<ref bean="UserinfoDAO"/>
</property>
</bean>

 -->

<bean name="test" class="org.zh.struts.action.TestAction">
<property name="igetinfo">
<ref bean="getinfo" />
</property>
</bean>


</beans>

解决方案 »

  1.   

    struts-config.xml 文件内容
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><struts-config>
      <data-sources />
      <form-beans >
        <form-bean name="testForm" type="org.zh.struts.form.TestForm" />  </form-beans>  <global-exceptions />
      <global-forwards />
      <action-mappings >
        <action
          attribute="testForm"
          
          name="testForm"
          path="/test"
          scope="request"
        
          type="org.springframework.web.struts.DelegatingActionProxy">
          <forward name="result" path="/result.jsp" />
        </action>  </action-mappings>
      <!--  
      
      <action-mappings >
        <action
          attribute="testForm"
          
          name="testForm"
          path="/test"
          scope="request"
          type="org.zh.struts.form.TestForm">
          <forward name="result" path="/result.jsp" />
        </action>  </action-mappings>
    <controller
    processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
    </controller>
      -->
      
      <message-resources parameter="org.zh.struts.ApplicationResources" />
      
      <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
      </plug-in>
    </struts-config>
      

  2.   

    看提示发现不能读取 applicationContext.xml 这个文件
    但是我仔细核对了 struts-config.xml 文件里的 插件加载代码,并且试了2中方式,都是同样的错误
    有没有高手来看看是为什么....
      

  3.   

    插件配置没有问题,关键是applicationContext.xml文件并不在web server中WEB-INF/classes目录下。仔细核对applicationContext.xml文件是不是放在了WEB-INF目录下了,如果不改配置,它应该在src目录下才对。
      

  4.   

    路径有问题,查看一下你的xml文件调用的路径。null的错误是xml文件没找到所以导致的错误
      

  5.   

    这个说得不错,如果把struts-config.xml里的路径修改以后还是报同样的错误的话,到TOMCAT的WORKAPPS里的东西删掉。再重启服务!搞定