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).方法()

 

posted @ 2016-06-28 17:35  乱世_独自美  阅读(102)  评论(0)    收藏  举报