快速搭建SSH三大框架(spring2.5)
1.创建web项目,名称为jboa
?
2.创建java package
?? cn.jbit.jboa.action 表示层struts action
?? cn.jbit.jboa.dao 数据访问层
?? cn.jbit.jboa.dao.hibimpl
?? cn.jbit.jboa.service 业务层
?? cn.jbit.jboa.service.impl
?? cn.jbit.jboa.entity 实体类
?? cn.jbit.jboa.util? 工具包
??
3.配置myeclipse "DB Browser工具",让myeclipse连接到oracle实例。
?
4.使用myeclipse为项目添加hibernate支持
? 3.1 选择hibernate-core为库包,并将jar文件拷贝到项目中
? 3.2 选择自动生成hibernate.cfg.xml
? 3.3 不创建HibernateSessionFactory工具类
?
5.使用myeclipse工具生成实体类及映射文件
? 注:生成实体类时指定类名,及对象属性类型。
?
6.使用myeclipse工具添加spring支持.
? 注:(1)添加库包时,选择spring-core,spring-aop,spring-persistence-core,spring-web
? (2)选择将jar文件拷贝到项目中。
?
7.配置spring监听器,应用启动时即加载spring配置文件。
??????? <context-param>
??<param-name>contextConfigLocation</param-name>
??<param-value>classpath:applicationContext.xml</param-value>
??<!-- 导入多个配置文件 -->
??<param-value>classpath:applicationContext-*.xml</param-value>
?</context-param>
?<listener>
??<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
?</listener>
?
8.配置spring OpenSessionViewFilter,解决hibernate延迟加载异常问题(如果没有配置关联关系,可以不配置此选项)。
?<filter>
??<filter-name>hibernateFilter</filter-name>
??<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
?</filter>
?<filter-mapping>
??<filter-name>hibernateFilter</filter-name>
??<url-pattern>*.action</url-pattern>
?</filter-mapping>
?
?<filter>
??<filter-name>ActionContextCleanUp</filter-name>
??<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
?</filter>
?<filter-mapping>
??<filter-name>ActionContextCleanUp</filter-name>
??<url-pattern>/*</url-pattern>
?</filter-mapping>
?
9.手动添加struts2支持(myeclipse8.5及以上支持自动添加struts2支持)
? 9.1 拷贝 struts2核心jar包及struts2-spring插件包。
? 9.2 修改web.xml配置主控制器Filter
? 9.3 添加struts.xml配置文件
?<filter>
?????? ??<filter-name>struts2</filter-name>
??????? ?<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
??? ?</filter>
?? ?<filter-mapping>
?????? ? ?<filter-name>struts2</filter-name>
?????? ? ?<url-pattern>/*</url-pattern>
??? ?</filter-mapping>
10.ok
?
?
?