`
minfirefox
  • 浏览: 83388 次
  • 性别: Icon_minigender_1
  • 来自: 太原
社区版块
存档分类
最新评论

Sturts2整合Spring一般步骤

阅读更多
步骤:
1.
导入Spring的包和struts2-spring-plugin-2.0.11.2.jar

2.
web.xml中加
<listener>
	<listener-class>
		org.springframework.web.context.ContextLoaderListener
	</listener-class>
</listener>

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>


3.
strust.xml中<struts>加
<constant name="struts.objectFactory" 
	value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>


4.
strust.xml
<action name="list" method="list" class="messageAction">
	<result>/list.jsp</result>
</action>


5.
applicationContext.xml
<bean id="messageAction" class="action.MessageAction" scope="prototype">
	<property name="messageService">
		<ref bean="messageService" />
	</property>
</bean>

其中<action> 中的class属性必须和<bean> 中的id属性一致,<bean> 中的class属性才是真正的类名。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics