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

spring 注入失败!!!!!!!!
applicationContext.xml
XML code

<bean id="userDao" class="com.quxiuna.dao.impl.UserDaoImpl">
        <property name="sessionFactory">
            <ref local="sessionFactory" />
        </property>
    </bean>
    <bean id="userService" class="com.quxiuna.service.impl.UserServiceImpl">
        <property name="userDao">
            <ref local="userDao" />
        </property>
    </bean>
    <bean id="loginAction" class="com.quxiuna.struts.action.login.LoginAction" scope="prototype">
        <property name="userService">
            <ref local="userService" />
        </property>
    </bean>


struts.xml
XML code

<struts>
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.objectFactory.spring.autoWire" value="type" />
    <include file="struts-default.xml"/>
    <include file="com/quxiuna/struts/action/login/loginAction.xml" />
</struts> 


loginAction.xml
XML code

<struts>    
     <package name="login" extends="struts-default" namespace="/login">    
         <action name="loginAction" class="com.quxiuna.struts.action.login.LoginAction">    
             <result name="success">/sendSuccss.jsp</result>
         </action> 
     </package>
</struts> 


web.xml
XML code

     <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>


UserServiceImpl.java
Java code

public class UserServiceImpl implements UserService {
    public UserDAO userDao;

    public UserDAO getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDAO userDao) {
        this.userDao = userDao;
    }



Java code

package com.quxiuna.struts.action.login;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.quxiuna.hibernate.po.RbacUser;
import com.quxiuna.service.UserService;
import com.quxiuna.util.Constants;

public class LoginAction extends ActionSupport {
    
    private static final long serialVersionUID = -1640288447822607013L;
    
    private String name;
    private String password;
    private String message;
    public UserService userService;

    public String getName() {
        return name;
    }