action在产生是可以放到两个容器中,一个是struts2中,一个是spring中。
1、放在struts中简单按照struts的配置,action中不用添加任何注解,容器会在初始化action时像spring容器查找action中的属性,默认按照name找不到按照type
2、利用注解放到spring容器中@Compent(),@scope()这两个注解需要在action中,由于放在spring中那么struts的容器不会再像spring容器中查找属性对应的bean,需要自己利用注解进行注入。在struts的xml中class可以写成@Compent()的名字
3、不能忘及@scope,如果不写会默认产生单利,那么在多线程下会出现问题。