社区
Web 开发
帖子详情
Struts2与Spring2配合使用如何获取ApplicationContext
boy002
2007-10-14 05:47:58
各位好,
请问在Struts2中如何获取Spring2的ApplicationContext对象,谢谢。
...全文
1002
5
打赏
收藏
Struts2与Spring2配合使用如何获取ApplicationContext
各位好, 请问在Struts2中如何获取Spring2的ApplicationContext对象,谢谢。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
sunyujia
2007-10-20
打赏
举报
回复
漏掉一个方法
/**
* 取得ServletContext
*
* @param context
* @return
*/
private ServletContext getServletContext(ActionContext context) {
return (ServletContext) context.get(SERVLET_CONTEXT);
}
sunyujia
2007-10-20
打赏
举报
回复
ActionContext ctx = ActionContext.getContext();
/**
* 取得spring的上下文环境
*
* @param session
* @return
*/
private WebApplicationContext getWebApplicationContext(ActionContext context) {
return WebApplicationContextUtils
.getWebApplicationContext(getServletContext(context));
}
nanjg
2007-10-19
打赏
举报
回复
ApplicationContext context=new ClassPathXmlApplicationContext(beans.xml);
classDemo demo = (classDemo)context.getBean();
或者
Resource res=new ClassPathResource(beans.xml);
BeanFactory bf=new XMLBeanFactory(res);
缘之一道
2007-10-14
打赏
举报
回复
整合spring+struts的话,有三中方案可解决,你可以参考相应的资料
必须在struts-config.xml注册spring的插件
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/config.xml"/>
</plug-in>
value=""为spring的配制文件位置
缘之一道
2007-10-14
打赏
举报
回复
如果只有一个配置文件,并且文件名为applicationContext.xml,则只需要在web.xml文件中增加如下代码即可: <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> 如果有多个配置文件需要加载,则使用<context-param>元素来确定配置文件的文件名。
最新版本的
Struts2
+
Spring
4+Hibernate4三大框架整合(改进:增加整合Quartz和Gson)
整合
使用
最新版本的三大框架(即
Struts2
、
Spring
4和Hibernate4),搭建项目架构原型。 项目架构原型:
Struts2
.3.16 +
Spring
4.1.1 + Hibernate4.3.6 + Quartz2.2.1。 此外,还有:Quartz、JUnit4、Log4j、SLF4J、...
Struts2
+
Spring
集成合并
前边单独总结了
Struts2
,
Spring
和Ibaits框架了,那么怎么结合
使用
呢?这次先来看一下Sturts2和
Spring
的集成合并。其实挺简单的,就是导入各自的jar包以及连接彼此的jar包,分好彼此的工作就可以了。 好看一下...
Struts2
与
Spring
整合
Struts2
与
Spring
整合后,可以
使用
Spring
的配置文件
applicationContext
.xml来描述依赖关系,在
Struts2
的配置文件struts.xml来
使用
Spring
创建的bean。 1、导入依赖包 除了导入
Struts2
和
Spring
的核心库之外,还要...
Struts2
与
Spring
整合.让
Spring
来管理action
Struts2
与
Spring
整合后,可以
使用
Spring
的配置文件
applicationContext
.xml来描述依赖关系,在
Struts2
的配置文件struts.xml来
使用
Spring
创建的bean。 1、导入依赖包 除了导入
Struts2
和
Spring
的核心库之外,还要...
Struts2
+
spring
+hibernate整合
第四章 搭建SSH框架 本章目标 掌握
Spring
与Struts 2的集成重点(难点) ... 以
Spring
作为核心框架,数据持久化
使用
Hibernate完成,表现层
使用
Struts 2
Spring
提供对象管理、面向切面编程等实用功能 通过...
Web 开发
81,094
社区成员
341,711
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章