DWR和Spring
让DWR和Spring一起工作的步骤
- 确认你用的是最新版的DWR。Spring创造器已经有了变化,所以你最好检查一下DWR的最新版本。
- 确认你查看过开始指南中的内容。
- 确认你的Spring的Bean在DWR外面运行良好。
- 配置DWR和Spring一起工作。 (看下面)
- 查看演示页面: http://localhost:8080/[ YOUR-WEBAPP ]/dwr ,检查spring的Bean是否出现。
DWR对于Spring没有运行期依赖,所以如果你不使用Spring那么Spring的支持不会产生任何影响到。
The SpringCreator
这个创造器会查找spring的中配置的Bean,用Spring去创建它们。如果你已经在使用Spring,那么这个创造器会非常有用。
你可以通过下面的方式来创建远程调用的Bean:
<allow>
...
<create creator="spring" javascript="Fred">
<param name="beanName" value="Shiela"/>
</create>
</allow>
寻找你的Spring配置
有三种方式寻找配置文件:
ContextLoaderListener
最简单的方式是使用org.springframework.web.context.ContextLoaderListener。你不必使用所有的Spring-MVC功能,只需要这个Listener就够了,所以这是个不错的方案。你需要在WEB-INF/web.xml中做如下配置:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/beans.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
我能找到的ContextLoaderListener的最好的文档就是javadoc。如果你知道还有更好的文档,请告知我。
Rob Sanheim 指出还有一个能深入了解ContextLoaderListener的文档。
使用location*参数
如果你要在dwr.xml中指定使用哪些bean,你可以使用location*参数。你可以指定任意多个文件,只要参数以location开始并且唯一即可。例如:location-1, location-2。这些location被用做Spring的ClassPathXmlApplicationContext的参数:
<allow>
...
<create creator="spring" javascript="Fred">
<param name="beanName" value="Shiela"/>
<param name="location" value="beans.xml"/>
</create>
</allow>
直接设置BeanFactory
SpringCreator有一个静态方法 setOverrideBeanFactory(BeanFactory) 用来通过编程的方式直接设置BeanFactory。
配置DWR和Spring
Bram Smeets写了一个有意思的blog,教你配置DWR使用beans.xml代替WEB-INF/web.xml。
我也对于如何在beans.xml中指定dwr.xml很感兴趣,尽管这看上去有些Spring传染病的感觉。有人知道如何实现吗?请加入邮件列表并告诉大家。
分享到:
相关推荐
dwr+spring集成配置 dwr采用annotation自动扫描的方式
DWR示例 包括DWR基本配置 DWR传递对象 DWR 反转ajax DWR与spring集成
将dwr集成到spring mvc(dwr的配置是基于xml)
《疯狂Ajax讲义:Prototype/jQuery+DWR+Spring+Hibernate整合开发》是《基于J2EE的Ajax宝典》的第二版。《基于J2EE的Ajax宝典》面市近2年,作为Ajax领域最全面、实用的图书,一直深受读者的好评。全书主要分为三个...
描述了spring和dwr配置文件的详细信息,dwr可以让JavaScript调用运行JAVA程序,可以方便我们的使用
使用dwr+spring实现消息推送 。
对spring mvc +dwr环境配置提供简单说明,适用于第一次使用dwr的初学者,其中dwr对应的jar包在另外一个资源中
dwr comet web push 服务器主动推送
配置整合DWR3.0和Spring2.5使用annotation注解
生成struts2 dwr spring 配置文件和数据操作类(com.comm 中BaseDao) idao层 dao层的实现类 Service 层和IService层 总的情况为 src 下有 com.comm BaseDao com.idao pojo所在的类的接口 com.daoimlp pojo所在...
spring+dwr实现用户名是否存在的判断
struts2.1 spring2.5 ibatis2.3 dwr3 annotation配置 集成 此中例子不完整. 如要下载:http://download.csdn.net/source/2138885
ExtJS DWR Spring 组合示例
源码 博文链接:https://callan.iteye.com/blog/166986
使用注解整合ext dwr spring hibernate
讲解Dwr spring 资料整合 非常有利于 新手学习DWR框架 让 一切变得更加简单
dwr与 spring整合 传对象的例子
dwr与spring集成的两种方式,来之网上搜索的文档。。
NULL 博文链接:https://json20080301.iteye.com/blog/1892385