8、写Service层的接口,并写实现该接口的类,在该类中要定义一个EmpDAO 类型的属性,并写其get和set方法。在此类的方法中调用DAO层中的方法。
9、写Action类,继承Action,在该类中定义一个EmpService类型的属性,并写其set方法,然后在execute方法中进行操作。
10、将DAO、Service中所有的类和Action类注入到applicationContext.xml的Bean中,而且有属性的一定要配置属性,然后在Struts-config.xml中写 :
<action path="/addEmp" //注:此处的path应与applicationContext.xml中 的name一致,Action注入bean时应用name而不用id
name="addEmpForm"
attribute="addEmpForm"
scope="request"
input="/addEmp.jsp" type="org.springframework.web.struts.DelegatingActionProxy">//代理
<forward name="success" path="/addSuccess.jsp"></forward>
</action>