MVC指model, view, controller
model指具体的业务逻辑,包括业务逻辑和数据库,其中业务由spring负责,数据库由hibernate负责用对象操作数据库
struts包括view和controller,view是jsp,controller可以认为是servlet,在struts中叫ActionServlet,负责对浏览器的请求进行转发至model
1 ,在里面定义两个spring配置文件 分别为hibernateContext.xml和applicationContext.xml 。hibernateContext.xml是把sessionFactary注入到各个DAO中去。
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
2,spring的作用是管理action,他需要把各个DAO注入到action中去,applicationContext.xml 这样action就可以直接调用DAO了,所以在basceAction中要定义所有set DAo的数值。
3,structs通过 type="org.springframework.web.struts.DelegatingActionProxy"把所有的path转发给spring 控制的action 通过path(structs),和name来匹配
4,编程的整个流程:
1)struts的 配置文件为核心,他将用户的每个请求 相当与path 转到spring的代理类中
2)spring 通过他的bean name的匹配 ,找到各个class,相当action,同时将这个action需要的DAO注入
3)action执行,返回页面,页面通过mapping.findForwd找到