日期:2014-05-17  浏览次数:20737 次

ssh spring不知道问啥无法注入
XML code

<bean id="sql" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
        </property>
        <property name="url"
            value="jdbc:sqlserver://localhost:1433;databaseName=hr_db">
        </property>
        <property name="username" value="sa"></property>
        <property name="password" value="sa"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="sql" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.SQLServerDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/ssh/entity/Users.hbm.xml</value></list>
        </property></bean>
        
        <!-- dao -->
        <bean id="baseDao" class="com.ssh.dao.BaseDao">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
        <bean id="userDao" class="com.ssh.dao.UsersDao" parent="baseDao">
            <property name="baseDao" ref="baseDao"></property>
        </bean>
        
        
        
        <!-- biz -->
        <bean id="userBiz" class="com.ssh.biz.UsersBiz">
            <property name="userDao" ref="userDao"></property>
        </bean>
        
        <!-- action -->
        <bean name="/users" class="com.ssh.web.action.UsersAction">
            <property name="userBiz" ref="userBiz"></property>
        </bean>
        </beans>



XML code

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="usersForm" type="com.ssh.web.form.UsersForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="usersForm"
      input="/login.jsp"
      parameter="o"
      name="usersForm"
      path="/users"
      scope="request"
      type="com.ssh.web.action.UsersAction" />

  </action-mappings>

  <message-resources parameter="com.ssh.web.ApplicationResources" />
   <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property 
            property="contextConfigLocation"
            value="classpath:applicationContext.xml" />
  </plug-in>
  
</struts-config>



java.lang.NullPointerException
at com.ssh.web.action.UsersAction.execute(UsersAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionP