SSH框架注解整合(非maven)
1. 创建web项目
2. 导jar包
3. 在src目录下准备一堆配置文件
a) applicationContext.xml
b) struts.xml
c) db.propertes
d) log4j.propertes --可省略
4. 实体类,在实体类上使用hibernate注解
a) @Entity
b) @Table
c) @Id
d) @GeneratedValue(strategy=GenerationType.IDENTITY)
5. 在applicationcontext.xml中配置sessionFactory
6. 在web.xml中配置ContextLoaderListener, 启动服务器,看表是否会自动创建
7. 表自动创建,代表前面的配置没有问题,可以使用sessionFactory,然后在写dao接口,在dao中使用sessionFactory
8. 然后写service接口,调用dao接口
9. 由于hibernate没有事务无法提交,故配置声明式事务的注解形式
10. 写个测试跑service接口,确保service接口是不是正确
11. Service接口测试通过后,然后配置action
a) @Contrller
b) @Scope("prototype")
c) @Namespace("/")
d) @ParaentPackage("sturts-default")
e) @Action(name="",results={@Result(name="",location="",type="redirect")})
在web.xml中配置StrutsPrepareAndExecuteFilter
12. 写页面,测试