日期:2014-05-17 浏览次数:20832 次
package com.action; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.Dao.registrationDao; // public class registrationAction { private String name; private String dept; public registrationAction() { super(); } public registrationAction(String name, String dept) { super(); this.name = name; this.dept = dept; } public String execute(){ System.out.println("--------registrationAction--------"); //spring 管理DAO IOC ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); registrationDao DaoFactory = (registrationDao) ac.getBean("registration"); DaoFactory.addEmployee(name, dept); return "success"; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDept() { return dept; } public void setDept(String dept) { this.dept = dept; } }