`

struts1 之 ContextLoader组件

 
阅读更多
把action交给spring管理


参考链接:
1.http://www.blogjava.net/zJun/archive/2007/01/08/92417.html
2.http://love398146779.iteye.com/blog/909723
3.http://blog.sina.com.cn/s/blog_6848c4440100siua.html



一、spring和struts1.x

spring的一个jar包:spring-webmvc-struts.jar

<plug-in/>将struts的处理转给Spring了,由Spring IOC控制调用Struts中的组件,这样你就需要在Spring那个applicationContext.xml中加入Action相应的bean类

1.web.xml里配置struts-config.xml(struts1.x配置文件),Tomcat启动加载该文件。
<action name="treeForm" path="/tree" scope="request"
			parameter="actions"
			type="org.springframework.web.struts.DelegatingActionProxy">
			<forward name="select"
				path="/platform/common/treeSelect.jsp" />
			<forward name="defeat" path="/common/error.jsp" />
		</action>	
	
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
		<set-property property="contextConfigLocation"
			value="/WEB-INF/classes/spring/core/applicationContext-action.xml" />
</plug-in>
注意:此处的plug-in也可以注释掉,直接在applicationContext.xml里加载applicationContext-action.xml也可以	


2.applicationContext-action.xml
    <bean name="/frameTest" class="com.lenovo.example.web.action.FrameTestAction">  
		<property name="frameTestService" ref="frameTestService" />
	</bean>
	
	<bean name="/flowTest" class="com.lenovo.example.web.action.FlowTestAction">
		<property name="flowTestService" ref="flowTestService" />		
		<property name="flowService" ref="engineflowService"/>
	</bean>	




二、spring和struts2.x

通过struts2.x里的一个jar包,启动自动将struts2.x控制权给spring
spring的一个jar包:struts2-spring-plugin-2.1.8.1.jar
分享到:
评论

相关推荐

    struts2驱动包

    java-struts2.2的驱动包 2009-8-29 14:02:04 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production ...

    第17讲 Spring、hibernate和Struts2的整合

    ①在web.xml中配置ApplicationContext.xml,并使用ContextLoader监听器实例化spring容器 ②把action交给spring管理,即在spring配置文件中定义action Bean并使用依赖注入功能在action中注入业务Bean,同时修改作用域...

    ContextLoader 加载xml

    NULL 博文链接:https://yjgyjg4.iteye.com/blog/662723

    iriska:鸢尾花分类模型

    =伊里斯卡= 包含鸢尾花分类模型 使用包装纸 请参阅和以获取更多详细信息 安装 将iriska.jar导入到您的项目中 将Klassy添加为依赖项 repositories { jcenter() ... .setPetalLength( 1.23725924762744 )

    realtor:Klassy的房地产经纪人回归模型

    =房地产经纪人= ... Houser model = new Houser ( new ContextLoader ()); House house = House . builder() .houseSize( 2983 ) .lotSize( 9365 ) .bedrooms( 5 ) .granite( 0 ) .bathroom( 1 ) .build

    S2SH整合报错

    ERROR main org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in...

    spring源代码解析

    在这个上下文的基础上,和web MVC相关还会有一个上下文来保存控制器之类的MVC对象,这样就构成了一个层次化的上下文结构。在web容器中启动Spring应用程序就是一个建立这个上下文体系的过程。Spring为web应用提供了上...

    spring-web-2.5.jar

    org.springframework.remoting.caucho.Hessian1SkeletonInvoker.class org.springframework.remoting.caucho.Hessian2SkeletonInvoker.class org.springframework.remoting.caucho.HessianClientInterceptor.class ...

    SPRING API 2.0.CHM

    Hessian1SkeletonInvoker Hessian2SkeletonInvoker HessianClientInterceptor HessianProxyFactoryBean HessianServiceExporter HessianSkeletonInvoker HeuristicCompletionException HibernateAccessor ...

Global site tag (gtag.js) - Google Analytics