Java Web整合开发(16) -- Struts 2.x 概述

Struts2与Spring的整合

•Struts2框架为配合与Spring3框架进行整合,提供了相应的拦截器。
•该组件名为StrutsSpringObjectFactory,位于struts2-spring-plugin-2.2.1.1.jar中
•通过在struts.xml中的声明,便可直接使用该组件以实现整合。
 
struts.xml
6  <struts>
7      <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
8      <package name="strutsspring" namespace="/strutsspring" extends="struts-default">
9          <action name="login" class="LoginAction">
10             <result name="success">/success.jsp</result>
11             <result name="input">/index.jsp</result>
12         </action>
13     </package>
14 </struts>

ApplicationContext.xml

1  <?xml version="1.0" encoding="UTF-8"?>
2  <beans xmlns="http://www.springframework.org/schema/beans"
3         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4         xmlns:context="http://www.springframework.org/schema/context"
5         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
6         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
7  
8      <bean id="LoginService" class="model.LoginService">
9      </bean>
10 
11     <bean id="LoginAction" class="controller.LoginAction" scope="prototype">
12         <property name="loginService" ref="LoginService"/>
13     </bean>
14 </beans>

 

转载于:https://www.cnblogs.com/thlzhf/p/4377109.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值