日期:2014-05-17 浏览次数:20796 次
@Component("listAction")
@Scope("prototype")
public class ListAction extends ActionSupport {
    //@Autowired
    //@Qualifier("customerDAO")
    private CustomerDAO customerDAO;
    public String demo01() {
        HttpServletResponse response = ServletActionContext.getResponse();
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        response.setContentType("text/xml;charset=UTF-8");
        String str = "<root><success>true</success><totalCount>1158</totalCount><row><id>1</id><name>peter01</name><email>xxx@163.com</email></row><row><id>2</id><name>peter02</name><email>xxx@163.com</email></row></root>";
        out.write(str);
        List<Customer> list = customerDAO.listAll();
        System.out.println(list.size());
        return null;
    }
    public CustomerDAO getCustomerDAO() {
        return customerDAO;
    }
    @Resource(name = "customerDAO")
    public void setCustomerDAO(CustomerDAO customerDAO) {
        this.customerDAO = customerDAO;
    }
} public void testSave01() {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext_new.xml");
       
        ListAction listAction=ac.getBean("listAction",ListAction.class);
    }org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'listAction' must be of type [com.zq.demo.web.action.ListAction], but was actually of type [$Proxy16]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:361)