由于自己学习的版本比较落后,这里就不总结了
在我这个版本整合的过程中的几点问题:
1.在web.xml的配置过程中:
openSessionInViewFilter org.springframework.orm.hibernate3.support.OpenSessionInViewFilter openSessionInViewFilter /*
2.注:struts2 和 Spring 整合之后,Action 的 生成方式有两种
第一种:<action name="user" class="com.bjsxt.registration.action.UserAction">
这种方式 由 struts 创建Action,struts创建的Action有几个特点:
1.不需要写 @Resource Action一产生的时候呢,会到Spring容器里面去找它要注入的内容 (service,dao等)(只要有 get set 方法,默认就会按照 byName的方式 自动装配到Action中)
2.不需要写 @Component,因为,Action 是 struts管理的,写了只会在Spring容器中多出来个bean而已
3.不需要写 @Scope(“prototype”),默认设置就是每次访问都创建Action
第二种:<action name="user" class="u> 使用action标签中 class属性配合 @Component(“u”)
这种方式可以由 spring 创建Action,spring创建的Action特点:
0.在Action中需使用 @Component(“u”),来生成 Action 这个bean,
1.可以 指定 注入 bean的 具体名字 ,即可以使用 @Resource(name=””);
2.需要 使用@Scope(“prototype”)不要忘记,因为默认的应该是 ‘单例的’
注:struts2 和 Spring 整合之后,Action 的 生成方式有两种
第一种:<action name="user" class="com.bjsxt.registration.action.UserAction">
这种方式 由 struts 创建Action,struts创建的Action有几个特点:
1.不需要写 @Resource Action一产生的时候呢,会到Spring容器里面去找它要注入的内容 (service,dao等)(只要有 get set 方法,默认就会按照 byName的方式 自动装配到Action中)
2.不需要写 @Component,因为,Action 是 struts管理的,写了只会在Spring容器中多出来个bean而已
3.不需要写 @Scope(“prototype”),默认设置就是每次访问都创建Action
第二种:<action name="user" class="u> 使用action标签中 class属性配合 @Component(“u”)
这种方式可以由 spring 创建Action,spring创建的Action特点:
0.在Action中需使用 @Component(“u”),来生成 Action 这个bean,
1.可以 指定 注入 bean的 具体名字 ,即可以使用 @Resource(name=””);
2.需要 使用@Scope(“prototype”)不要忘记,因为默认的应该是 ‘单例的’