- 浏览: 2886064 次
- 性别:
- 来自: 武汉
-
文章分类
- 全部博客 (1173)
- 名言警句 (5)
- 心情随笔 (50)
- 数据库 (57)
- Java基础 (241)
- J2EE框架 (91)
- 数据结构 (12)
- 程序设计 (21)
- WEB技术 (128)
- 网络日志 (12)
- IT资讯 (247)
- linux (64)
- solaris (2)
- 其它 (143)
- WebService (4)
- 日语学习 (2)
- 机器人 (5)
- Android (5)
- cgywin (3)
- Game (1)
- DWR (1)
- spring (8)
- canvas (1)
- Guava (3)
- Modbus (5)
- 测试 (6)
- mongodb (9)
- Quartz (2)
- Cron (1)
- windows (2)
- 持续集成 (1)
- bootstrap (3)
- 结对编程 (1)
- nodejs (1)
- Netty (1)
- 安全 (3)
- webstorm (2)
- sparkline (1)
- Job (1)
- git (3)
- Maven (3)
- knockout (5)
- jquery (1)
- bower (1)
- docker (1)
- confluence (4)
- wiki (1)
- GoogleMap (1)
- jekyll (10)
- ruby (2)
- npm (3)
- browserify (1)
- gulp (3)
- openwrt (1)
- discuz (3)
- 输入法 (1)
- JPA (1)
- eclipse (2)
- IntelliJ (1)
- css (1)
- 虚拟机 (1)
- 操作系统 (1)
- azkaban (2)
- scrum (1)
最新评论
-
pangxiea_:
你好, 想请问一下 Linux下 这么使用rxtxcomm 在 ...
使用Java进行串口通信 -
abababudei:
请教一下,这个您是怎么解决的:/dev/ttyS2enteri ...
Java应用程序的MODBUS通讯 -
xuniverse:
hannibal005 写道楼主,我问下 request.se ...
用javascript与java进行RSA加密与解密 -
atxkm:
找了一下午,终于找到了
gulp 拷贝文件时如何移除文件目录结构 -
kalogen:
gtczr 写道非常感谢,经过我自己的修改,已经完美实现。发出 ...
用javascript与java进行RSA加密与解密
1、载入dwr的jar文件
下载地址:http://www.cnweblog.com/Files/jimmy/dwr.rar (将后缀名改为jar)
2、在web.xml中配制
<servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping>
3、在WEB-INF下建立dwr.xml和dwr20.dtd两个文件
复制以下内容到dwr20.dtd文件中,保存:
<?xml version="1.0" encoding="UTF-8"?> <!-- This is the DTD for DWR v2.x --> <!-- Top level conviguration element. --> <!ELEMENT dwr ( (init?), (allow?), (signatures?) ) > <!-- A list of all the classes to configure as part of dwr at startup time. --> <!ELEMENT init ( (creator | converter)* ) > <!-- Define a new method of creating objects for use by Javascript. We don't just allow access to any object and some may need special code to get a reference to them. --> <!ELEMENT creator EMPTY > <!-- @attr id The unique name by which create elements refer to us. @attr class The fully qualified name of a class that implements Creator. --> <!ATTLIST creator id ID #REQUIRED class CDATA #REQUIRED > <!-- Define a new way of converting between javascript objects and java objects. Many classes can have default conversion mechanisms but some require more custom conversion --> <!ELEMENT converter EMPTY > <!-- @attr id The unique name by which convert elements refer to us. @attr class The fully qualified name of a class that implements Converter. --> <!ATTLIST converter id ID #REQUIRED class CDATA #REQUIRED > <!-- Security: we must define which classes we are allowed to access because a free-for-all will be very dangerous. --> <!ELEMENT allow ( (create | convert | filter)* ) > <!-- Allow the creation of a class, and give it a name in javascript land. A reference to a creator is required as are some parameters specific to each creator that define the objects it allows creation of. It would be nice to make the creator and IDREF rather than a CDATA, since it refers to an element defined elsewhere, however we allow multiple dwr.xml files and we might refer to one in another file. --> <!ELEMENT create ( (param | include | exclude | auth | filter)* ) > <!-- @attr creator The id of the creator to use @attr javascript The name of the object to export to the browser @attr scope The scope of the created variable. The default is page. --> <!ATTLIST create creator CDATA #REQUIRED javascript CDATA #REQUIRED scope (application | session | script | request | page) #IMPLIED > <!-- A filter is a way to insert procesing tasks at various points during the processing of an Ajax call. See org.directwebremoting.AjaxFilter --> <!ELEMENT filter ( (param)* ) > <!-- @attr class The class name to use to filter requests --> <!ATTLIST filter class CDATA #REQUIRED > <!-- Some elements (currently only create although there is no hard reason why convert elements should not be the same) need customization in ways that we can't predict now, and this seems like the only way to do it. --> <!ELEMENT param (#PCDATA) > <!-- @attr name The name of the parameter to this creator @attr value The value to set to the names parameter --> <!ATTLIST param name CDATA #REQUIRED value CDATA #IMPLIED > <!-- A creator can allow and disallow access to the methods of the class that it contains. A Creator should specify EITHER a list of include elements (which implies that the default policy is denial) OR a list of exclude elements (which implies that the default policy is to allow access) --> <!ELEMENT include EMPTY > <!-- @attr method The method to include --> <!ATTLIST include method CDATA #IMPLIED > <!-- See the include element --> <!ELEMENT exclude EMPTY > <!-- @attr method The method to exclude --> <!ATTLIST exclude method CDATA #IMPLIED > <!-- The auth element allows you to specify that the user of a given method must be authenticated using J2EE security and authorized under a certain role. --> <!ELEMENT auth EMPTY > <!-- @attr method The method to add role requirements to @attr role The role required to execute the given method --> <!ATTLIST auth method CDATA #REQUIRED role CDATA #REQUIRED > <!-- Allow conversion of a class between Java and Javascript. A convert element uses a previously defined converter and gives a class match pattern (which can end with *) to define the classes it allows conversion of It would be nice to make the converter and IDREF rather than a CDATA, since it refers to an element defined elsewhere, however we allow multiple dwr.xml files and we might refer to one in another file. --> <!ELEMENT convert ( (param)* ) > <!-- @attr converter The id of the converter to use @attr match A class name to match for conversion @attr javascript The optional classname for the parameter --> <!ATTLIST convert converter CDATA #REQUIRED match CDATA #REQUIRED javascript CDATA #IMPLIED > <!-- If we are marshalling to collections, we need to be able to specify extra type information to converters that are unable to tell from reflection what to do. This element contains some Java method definitions --> <!ELEMENT signatures (#PCDATA) >
以下是dwr.xml的文件内容详解:
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "dwr20.dtd"> <dwr> <!-- without allow, DWR isn't allowed to do anything --> <allow> <create creator="new" javascript="js的名字"> <param name="class" value="类的地址"></param> </create> <!--举例--> <create creator="new" javascript="NewsTypeAjax"> <param name="class" value="com.jetsum.pbcbank.news.ajax.NewsTypeAjax"></param> </create> <!-- 整合Spring --> <create creator="spring" javascript="vbaoCommon"> <param name="beanName" value="vbaoCommonService"/> <include method="checkAuthcode" /> </create> </allow> <signatures> <![CDATA[ import java.util.List; ]]> </signatures> </dwr>
4、Ajax类的写法很简单,就和一般的类写法一样:
package com.jetsum.pbcbank.news.ajax; import com.jetsum.pbcbank.news.dao.TypeDao; public class NewsTypeAjax { public NewsTypeAjax() { } public boolean checkNewsTypeExist(String typename) { boolean result = false; TypeDao dao = new TypeDao(); if(dao.newsTypeExist(typename)) result = true; return result; } }
5、页面上调用写好的dwr:
<!--在导入自定义的dwr之间必须先导入/dwr/engine.js和dwr/util.js否则会报错--> <script language="javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script> <script type='text/javascript' src="<%=request.getContextPath()%>/dwr/util.js"></script> <!--导入自定义的dwr文件,即dwr.xml中所配制的js名,前面加上/dwr/interface/路径--> <script type='text/javascript' src="<%=request.getContextPath()%>/dwr/interface/NewsTypeAjax.js"></script> <script type="text/javascript"> <!--举例--> function typeExist(){ <!-- 1、获取页面数据--> var typename=document.getElementById('newtypename').value; typename=typename.replace(/(^\s*)| (\s*$)/g, ""); if(typename.length==0){ alert('请输入新闻类型名称'); document.getElementById('newtypename').focus(); return false; } <!-- 2、设置为异步的,一般情况下为异步--> DWREngine.setAsync(false); <!-- 3、调用写好的ajax类中的方法,有两个参数,第一个是传入方法的数据,第二个是回调函数,flag为调用的方法所返回的值。--> NewsTypeAjax.checkNewsTypeExist(typename,function (flag){ if(flag==true) { alert("该新闻类别已经存在!"); return false; } else { add(); } }); </script>
发表评论
-
30个你必须熟记的CSS选择器
2015-06-27 08:44 1783你学会了基本的id,class类选择器和descendant ... -
40 个超棒的免费 Bootstrap HTML5 网站模板
2015-04-11 16:12 2904Bootstrap 是快速开发Web应用程序的前端工具包。它 ... -
必须记住的 30 类 CSS 选择器
2014-12-30 08:56 1012大概大家读知道`id`,`class`以及`descenda ... -
如何防止google map 加载Roboto字体
2014-12-26 13:16 889思路是在window.onload中当检测到加载Roboto ... -
JavaScript Equality Table
2014-12-09 16:17 1902Tables displaying the issue: ... -
WebStorm快捷键收集
2014-11-25 10:40 30191、webstorm快捷键: IntelliJ-Idea ... -
webstorm 常用快捷键
2014-08-25 15:58 958常用快捷键 Ctrl+/ 或 Ctrl+Shift+/ ... -
how to change bower components folder
2014-08-25 09:26 7861. create the file bower.json ... -
程序员应该知道的 13 个设计技巧
2014-07-14 09:34 757开发你的美感 … 我最喜欢的站点是: a ... -
tomcat7中tomcat-users.xml配置
2014-04-26 15:48 722将以下代码加入tomcat-users.xml中,即可登录t ... -
tomcat-maven-plugin的使用
2014-03-04 10:52 894环境: Ubuntu 8.10, tomcat6, ma ... -
Jsp动态显示服务器时间
2013-12-31 13:16 1092<script language=" ... -
前端工程与性能优化(下):静态资源管理与模板框架
2013-09-25 08:57 1004本系列文章从一个全新的视角来思考web性能优化与前端工程之间 ... -
前端工程与性能优化(上):静态资源版本更新与缓存
2013-09-20 09:35 985每个参与过开发企业级 ... -
Handy and Useful jQuery Snippets for Developers
2013-09-18 15:43 818jQuery is a cross browser Java ... -
11 个用来创建图形和图表的 JavaScript 工具包
2013-08-13 07:00 1378Aristochart DEMO || Download ... -
Jive 论坛 license破解
2013-08-03 13:27 13411. 找到文件 \admin\global.jspf 注释 ... -
2012年度最佳Web前端开发工具和框架
2013-01-10 10:52 17862012年,Web 开发领域继续在快速的发展,HTML5 ... -
为网页设计师准备的 10 个色彩方案生成器
2012-02-22 23:01 1225Pictaculous ColorExplo ... -
13个最常用的CSS和HTML快速开发工具
2012-02-21 08:18 12861)CleverCSS CleverCSS ...
相关推荐
在“dwr2.0最简单例子实用亲测试”中,我们可以预期这是一个关于如何使用DWR 2.0版本的入门教程,包含了实际可运行的示例代码。下面将详细介绍DWR的基本概念和在这个实例中可能涉及的关键知识点: 1. **DWR的核心...
Direct Web Remoting (DWR) 是一种开源Java库,它允许在Web应用程序中实现JavaScript与...DWR不仅可以用于简单的数据获取,还可以支持更复杂的交互,如异步数据更新、文件上传等,极大地增强了Web应用的功能和性能。
DWR通过AJAX技术提供了一种简单的方法来更新网页的部分内容,而无需刷新整个页面,提高了用户体验。这个"TestDwr"压缩包文件提供的例子是一个简单的DWR应用示例,适合初学者理解和学习。 1. **DWR基本概念**: - ...
**DWR(Direct Web Remoting)实用例子小集** DWR(Direct Web Remoting)是一种在Web应用程序中实现Ajax(Asynchronous JavaScript and XML)技术的Java库。它允许JavaScript在客户端与服务器端进行直接交互,使得...
1. **DWR框架概述**:DWR允许Web应用程序在客户端和服务器之间交换数据和调用方法,提供了丰富的API和配置选项,使得前后端交互更加简单。 2. **DWRUtil类**:DWRUtil是DWR提供的一系列实用工具函数的集合,包括但...
**DWR(Direct Web Remoting)实用案例** DWR 是一个开源 Java 库,它允许在浏览器和服务器之间进行实时的、双向的通信,无需使用插件或 Flash。这一技术极大地简化了 AJAX 应用程序的开发,因为它提供了一种简单的...
总结来说,DWR作为Ajax开发的利器,通过其简单易用的API和丰富的功能,可以帮助开发者快速构建动态、交互性强的Web应用。结合参考书和实际案例,深入学习DWR,不仅可以提升技能,也能更好地理解和应用Ajax技术。
DWR作为一种简单实用的小型Ajax框架,通过简化前后端之间的通信流程,提高了开发效率和用户体验。通过本文档的学习,你可以了解到DWR的基本使用方法及其与各种Java Web框架的整合技巧,从而更好地利用DWR完成项目...
《实用DWR 2项目》一书由Frank W. Zammetti撰写,是关于DWR(Direct Web Remoting)框架的深入指南。本书通过六个完整的Web 2.0应用程序实例,详细介绍了如何利用DWR这一在Ajax领域备受瞩目的库进行设计与构建。 ##...
DWR简化了客户端JavaScript与服务器端Java对象之间的交互,提供了简单易用的API,使得开发人员可以像调用本地方法一样调用服务器上的方法。 DWR的核心功能包括: 1. **自动处理JavaScript与Java之间的类型转换**:...
自己写的Quartz例子简单实用。包含所有jar包,部属到tomcat下就可运行。tomcat窗口启动后每10秒调一次execute()。另外还用到了DWR,在jsp中点submit就会发送异步请求回调rollBack方法。简单明了,很适合初学者!
Direct Web Remoting (DWR) 是一个开源Java库,它允许Web应用程序在客户端JavaScript和服务器端Java之间进行安全、简单的异步通信。这个教程包含了DWR的核心组件和使用示例,帮助开发者理解并掌握DWR的技术特点和...
DWR的核心功能是提供了一个简单的方法来调用服务器上的Java方法,并将结果直接返回到客户端的JavaScript中。 本套DWR学习资料旨在帮助初学者快速掌握DWR的基本概念和使用技巧。通过实例和详细的说明,你可以系统地...
在这个"模拟DWR写的小例子"中,我们将探讨DWR的基本原理、核心功能以及如何通过一个简单的实例来理解和应用DWR。 DWR的核心思想是提供了一种安全、高效的方法,使得JavaScript可以调用服务器上的Java方法,就像是...
5. **小demo**:这个项目可能包含了一个简单的示例,演示了如何在J2EE环境中集成DWR,以及如何使用DWR进行后台交互的基本步骤,这对于初学者理解和学习DWR非常有帮助。 6. **标签“dwr”**:这个标签明确了项目的...
DWR提供了一系列实用工具(如DWR Util)来帮助处理HTML表单、SELECT元素、TABLE等。例如,`DWRUtil.setValue`可以方便地设置表单元素的值,`DWRUtil.fillSelect`用于填充SELECT选项,`DWRUtil.update`可以更新指定的...
6. **测试DWR集成**:完成以上步骤后,可以通过编写简单的客户端脚本来测试DWR是否能够正常工作。例如,在HTML页面中调用服务器端的方法。 #### 四、解决XML验证错误 根据题目中的描述,在实践中可能会遇到XML验证...
总之,"dwr3实现的无刷新文件上传"是一个实用的教程,可以帮助开发者理解DWR3如何简化Ajax开发,特别是文件上传这一常见任务。通过学习和实践这个项目,开发者可以提升自己的技能,并将这些知识应用到更复杂的Web...