1.首先一个ssh项目做好之后,首先得发布到tomcat上,所以第一步会先加载web.xml
2.web.xml中首先会加载spring的监听器ContextLoaderListener,监听器会监听servletContext对象,这样就加载spring的配置文件applicationContext.xml
3.在applicationContext.xml中
①配置数据源datasource,数据库中信息都会存放在一个属性文件中因此我们要配置外部属性文件db.properties
②配置sessionFactory对象(localSessionFactoryBean),在sessionfactory对象中
1.注入datasource 2.注入hibernate.cfg.xml核心配置文件
4.配置事务管理(1.xml 2.注解)
5.dao对象
6.service对象
7.action对象(多例)
8.web.xml中还会加载struts2的核心过滤器StrutsPrepareAndExecuteFilter
9.加载struts.xml
当我们发送请求customerAction_findCustom.action ,核心过滤器会拦截请求,然后再struts.xml中配置
<action name="customerAction_* class=“spring中的bean的id” method={1}>
然后spring的配置文件applicationContext.xml会将action实例化并创建出来,action会调用service,service调用dao,dao查询数据库 返回结果,然后在一步步返回,struts.xml中配置视图 查询的数据保存在值栈或域中,通过EL或者OGML等在jsp页面上展示出来
这是我自己的理解,也有不全的希望大家多包涵