首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Spring 2.0 调整 struts 1.2 的配置方法

2012-10-19 
Spring 2.0 整合 struts 1.2 的配置方法Spring 2.0 整合 struts 1.2 的配置方法使用IDE:myEclipse先将所需

Spring 2.0 整合 struts 1.2 的配置方法
Spring 2.0 整合 struts 1.2 的配置方法

使用IDE:myEclipse

先将所需jar包加入到web-inf文件的lib文件夹下,myEclipse可以自动帮你完成,在这就不多说了。

第一步:

在struts-config .xml配置文件中增加一行如下:

<controller processorscope="request">

<property name="dao" ref="testDao" />

</bean>

<bean id="testDao" parameter="action" path="/testAction" validate="false">

<forward name="test" path="/test.jsp"></forward>

</action>

</action-mappings>
* 必须使name属性,name属性值必须和struts-config.xml文件中的<action>标签的path属性值一致
* 建议将scope设置为prototype这样就避免了struts action的线程安全问题

总结,解决了依赖查找,使用依赖注入,它没有侵入性。

完成这个设置后,strus会将截获到的用户请求转发到spring context下的bean,根据bean的name属性来匹配。如果配置default-autowire="byName" ,会更简单一些。

热点排行