DWR全面解析.doc
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
![preview](https://dl-preview.csdnimg.cn/85747286/0001-e9abf5ccfe6b1b9e5e880bceca0c8af3_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
DWR (Direct Web Remoting) 是一个开源的Java库,专为构建AJAX(Asynchronous JavaScript and XML)Web应用而设计。它使得JavaScript代码能够在客户端浏览器中直接调用服务器端的Java方法,仿佛这些Java代码就在浏览器环境中执行一样。DWR通过异步通信,提高了Web应用的交互性和用户体验。 在使用DWR之前,了解远程调用方法是基础。通常,我们通过HTTP请求与服务器进行交互,但DWR简化了这一过程,允许JavaScript直接调用Java类的方法,无需处理复杂的HTTP请求和响应。 DWR的配置涉及到两个主要的文件:`web.xml`和`dwr.xml`。在`web.xml`中,你需要添加DWR的Servlet配置,包括启用调试模式和其他必需的设置。`dwr.xml`是DWR的核心配置文件,它定义了哪些Java类和方法可以被JavaScript访问。在这个文件中,你可以使用`<allow>`标签指定可创建和转换的类,`<create>`标签用于指定Spring集成,`<param>`标签则关联到Spring的bean实例。 在`beans.xml`中,你需要定义你想要远程调用的类,并作为bean注入。`<include>`或`<exclude>`标签用来指定哪些方法可以或不可以被JavaScript调用。`<include>`标签包含可调用的方法,而`<exclude>`标签则排除某些方法。不过,通常建议只明确包含需要的方法,而不是排除不需要的,以保持配置的清晰。 在JavaScript中使用DWR时,首先需要引入DWR生成的JS文件(如`DwrTime.js`),以及DWR的核心库文件(`engine.js`和`util.js`)。这些文件提供了与服务器交互的API和一些实用工具。例如,`DwrTime.currentlyTime()`方法就是在JavaScript中调用Java的`currentlyTime()`方法,`callBackTime`参数是一个回调函数,当Java方法执行完成并返回结果时会被调用。 DWR与Spring的整合使用,使得我们可以利用Spring的依赖注入和管理功能,轻松地将业务逻辑与视图层解耦。DWR不仅限于简单的CRUD操作,还能处理更复杂的数据交换和业务流程。然而,DWR的高级特性、优化策略和安全考虑并未在此详细展开,如需深入了解,推荐查阅更深入的文档和教程。
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/release/download_crawler_static/85747286/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/85747286/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/85747286/bg3.jpg)
![](https://csdnimg.cn/release/download_crawler_static/85747286/bg4.jpg)
![](https://csdnimg.cn/release/download_crawler_static/85747286/bg5.jpg)
剩余63页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/acfce43ffe2c41f996326bd927946824_yhsbzl.jpg!1)
- 粉丝: 3719
- 资源: 59万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)