`
yonglin4605
  • 浏览: 183607 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

GWT与Spring的整合

    博客分类:
  • GXT
阅读更多
在使用GWT的RPC时,我们一般会创建一个类继承RemoteServiceServlet
这样就可以时候GWT提供给我们的RPC调用了。

RemoteServiceServlet继承了HttpServlet,要想与Spring整合,只需要覆写HttpServlet中的
public void init(ServletConfig config) throws ServletException 方法即可
public class BaseService extends RemoteServiceServlet {
	protected WebApplicationContext springContext;

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		springContext = WebApplicationContextUtils.getWebApplicationContext(
				config.getServletContext(),
				WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
	}
}


之后我们所有的类都继承这个BaseService,就可以拿到Spring上下文springContext了
通过:
Object obj=springContext.getBean("object");

拿到spring注入的类
分享到:
评论
1 楼 xjh19951574 2012-08-18  
正好用上,十分感谢。

相关推荐

Global site tag (gtag.js) - Google Analytics