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

Spring注入后Action接收不到!!
我的Spring在服务器启动时被注入,但是在Action中,当Action被访问,那么注入的属性都变为null~求解啊!!!


2011-10-11 17:57:53 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
ServiceDAO真心注入了 sun.common.ServiceDAO@71cb25
com.news.app.user.UserService@c510e3
2011-10-11 17:57:56 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2011-10-11 17:57:56 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Test
2011-10-11 17:57:56 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-80
2011-10-11 17:57:56 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2011-10-11 17:57:56 org.apache.catalina.startup.Catalina start
信息: Server startup in 6294 ms
null
com.sun.dao.FirstTypeDAOImpl@993730
Action代码
Java code

package com.news.app.user;

import java.sql.SQLException;

import com.sun.dao.FirstTypeDAOImpl;


import sun.common.SunActionSupport;

public class UserAction extends SunActionSupport{
    private UserService userService;
    private FirstTypeDAOImpl firsttypeDAO;
    
    



    public FirstTypeDAOImpl getFirsttypeDAO() {
        return firsttypeDAO;
    }

    public void setFirsttypeDAO(FirstTypeDAOImpl firsttypeDAO) {
        this.firsttypeDAO = firsttypeDAO;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public String add() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String addView() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String delete() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String edit() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String editView() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String list() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }
    
    //登录LoginAction
    public String Login() throws SQLException{
        System.out.println(userService+"\n"+firsttypeDAO);
//        if(condition=="login"){
//            System.out.println(user.getUser_name());
////            getSession().put("user_name", user.getUser_name());
////            getSession().put("password", user.getPassword());
////            getSession().put("user_lvl", user.getUser_lvl());
//            System.out.println("登录成功");
//            return LOGIN;
//        }
//        else{
//            System.out.println("登录失败");
//            return ERROR;
//        }
        return "login";
        
    }

    @Override
    public String search() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

}


Service代码
Java code

package com.news.app.user;

import java.sql.SQLException;

import sun.common.ServiceDAO;
import sun.common.newsService;

import com.sun.dao.UserDAO;
import com.sun.vo.UserExample;

public class UserService implements newsService{