M(dao)進行實際操作 service調dao,contronller(action)調用service,service依賴(調用)dao,action調用service
目錄結構
service中必須有dao的set get方法,action中必須有service的setget方法,且屬性名應與xml中配置的一致
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<beans>
<bean id="user" class="com.bean.User" ></bean>
<bean id="udao" class="com.dao.UserDaoImpl" ></bean>
<bean id="uservice" class="com.service.UserServiceImpl" >
<property name="udao" ref="udao"></property>
</bean>
<bean id="uaction" class="com.action.UserAction" >
<property name="service" ref="uservice"></property>
</bean>
</beans>
</beans>
【類中變量名必須和xml中一致!!!!!!!】