SSH框架随写

来源:互联网 发布:线阵音响和矩阵的区别 编辑:程序博客网 时间:2024/06/10 08:47

笔记下SSH框架调用流程

主要在包中有以下包

Filter(过滤器)
interceptor(拦截器)
action(View层)
service(业务逻辑层)
model-dao(数据持久层)
model-Entity(实体层)
Util(组件)

主要配置文件
hibernate.cfg.xml(hibernate配置文件)
applicationContext.xml(Spring配置文件)
struts.xml(struts2配置文件)
web.xml(web项目配置文件)

Maven
项目名称 *.iml(jar配置文件)

web.xml

web.xml中配置监听器,过滤器,主界面(欢迎界面)
Spring监听器
Struts2过滤器
主界面配置

applicationContext.xml

Spring两大特点 IOC和AOP
Spring整合hibernate,所以比较多的bean,sessionFactory
所以在Spring中即配置bean和aop事物管理
有的在这里配置数据源,我在hibernate中配置

hibernate.cfg.xml

配置hibernate各种配置及mapping(数据源或者不配置)

struts.xml

配置action,及拦截器,推荐使用注解方式配置

调用步骤

web.xml加载配置Spring,struts2,拦截器,监听器。(好吧其实Spring和struts2就是拦截器和监听器。后面只自定义或额外加载)

访问网页->过滤器->拦截器->action->service->dao

主要使用的是JSONObject,返回数据json格式
通过过滤器,拦截器等手段控制安全(登陆验证等)

以上为记录,后续待写。