读书人

运用annotation注解整合DWR3 + Spri

发布时间: 2012-11-23 00:03:43 作者: rapoo

使用annotation注解,整合DWR3 + Spring3 + Hibernate3

首先参考了wangcheng的一个博客:http://wangcheng.iteye.com/blog/409548

?

因为我的Spring已经是使用annotation注解,所以现在加入DWR框架一样使用annotation注解,Spring、Hibernate文件配置这里不做解释。

1.系统的业务类:

?

? ? ? 为了跟之前的系统代码相分离,我新建立了一个xml文件,叫“applicationContext-dwr.xml”,内容就是上面的xml文件。

简单解释一下这些配置

??<dwr:annotation-config /> 要求DWR在Spring容器中检查拥有@RemoteProxy 和 @RemoteMethod注解的类。注意它不会去检查Spring容器之外的类。

??<dwr:url-mapping /> 要求DWR将util.js和engine.js映射到dwrController

??<dwr:controller id="dwrController" debug="true" /> 定义dwrController

??<dwr:configuration /> 此标签在这个例子中不是必须的,如果你想配置Spring容器之外的类,就需要它了。

?

总结:

? ? ? 至此,配置完成。

? ? ? 访问:http://127.0.0.1:8080/SHIPLOCK/dwr/test/ShipLockSchedulManager,如果看到以下内容,说明已经成功了。http://127.0.0.1:8080/SHIPLOCK/dwr/test/这一段是固定的,后面那个是java类的名称。

Methods For: ShipLockSchedulManager。。。。。?

最后我们写一下测试页面:

?

?运行一下:

运用annotation注解,整合DWR3 + Spring3 + Hibernate3

读书人网 >Web前端

热点推荐