SSH+MVC的进一步优化
接口dao--------->dao1
---------->dao2
----------->dao..
在xml中将所有dao分支放入集合中,如下:
<util:map id="map" map-class="java.util.HashMap"> <entry key="teacherDao" value-ref="teacherDao"></entry> <!-- 可以有n多个dao的bean --> </util:map>
xml头需要引入:
xmlns:util="http://www.springframework.org/schema/util" ...... http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
在service层就可以调用集合中任意dao的任意方法了:
daoMap.get(key).方法()


浙公网安备 33010602011771号