ssh的初始配置

一 创建web项目,引入相应的jar包
1 复制jar包(ctrl+c)
2 粘贴到web-inf下面的lib文件夹
struts2:
3 配置web.xml中的filter和filter-mapping
4 配置struts.xml:
src下面新建xml,dtd,选apache configuration 2以上的

hibernate:
5 创建实体以后配置hibernate映射文件

spring:
6 web.xml中配置


7 applicationContext.xml
8 log4j.properties的配置:

jar包保存在F盘:大四上 二维码签到项目 ssh框架中

ssh的三种配置方式:
1 带有hibernate配置文件
2 不带hibernate配置文件
3 纯注解

1 重点了解的jar包:
structs2-convention-plugin:
structs2注解开发的jar包

structs2-spring-plugin:
structs2用于整合spring的jar包

slf4j整合log4j的jar包

2 需要配置的jar包:
(注:spring进行ioc或aop开发,所需要的jar包不同)

二 引入相应的配置文件
1 structs2:
web.xml (核心过滤器)
struts.xml(纯注解整合中可被省略)

2 hibernate:
hibernate.cfg.xml (可省略)
映射的hbm.xml

3 spring配置文件:
web.xml (核心监听器listener)
applicationcontext.xml

log4j.properties

三 创建包结构和实体
包结构:
…action
…service
…dao
…domain(实体放在这里)

第四章 struts2整合spring

四 创建页面(保存商品的页面)
写一个jsp
注:使用struts2的标签库,不要在头上忘了写

五 编写 action,service,dao
0 service中的dao注入
1 action 中的service注入:
引入了spring-structs-plugin的包之后,就不需要再通过webapplicationcontext注入了。可以直接用Setter方法注入。

(注:
struts2和spring整合的两种方式:
1 action的类由struts2自身创建
2 action的类由spring创建(建议使用,从而方便交给aop进行管理))

2,3 service和dao直接在applicationcontext.xml中进行配置

其他:
1 用open type查找类的全程:
ctrl + shift +T

猜你喜欢

转载自blog.csdn.net/wjl960827/article/details/82925722