- 浏览: 161735 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
jiangyeqt:
好好的温习了一遍,讲的非常的到位
Session的原理 -
JAVA静静:
这是什么啊?有没有源码?看不懂诶!
开源框架Pushlet入门 -
colinzhy:
讲的很深刻,学习了
Session的原理 -
昔雪似花:
...
Map-iterator -
不相信眼泪:
恩,很好,多谢
.scc文件是做什么用的?
1 web.xml
2 dwr.xml
3 User.java
4 AutoSuggest.java
5 CharacterEncodingFilter.java
6 autosuggest.css
<!------ AutoSuggest/WebContent/WEB-INF/web.xml ---->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="dwr">
<display-name>Auto Suggest Demo</display-name>
<description>Test for Auto Suggest</description>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>test.joeyta.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="dwr">
<display-name>Auto Suggest Demo</display-name>
<description>Test for Auto Suggest</description>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>test.joeyta.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<description>Direct Web Remoter Servlet</description>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
</web-app>
2 dwr.xml
<!------ AutoSuggest/WebContent/WEB-INF/dwr.xml ---->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="AutoSuggest">
<param name="class" value="test.joeyta.AutoSuggest"/>
</create>
<convert match="test.joeyta.User" converter="bean"></convert>
</allow>
</dwr>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.ltd.uk/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="AutoSuggest">
<param name="class" value="test.joeyta.AutoSuggest"/>
</create>
<convert match="test.joeyta.User" converter="bean"></convert>
</allow>
</dwr>
3 User.java
/** *//************** User.java ************************/
package test.joeyta;
public class User implements Comparable {
private String name;
private String tel;
public User(){}
public User(String name, String tel){
this.name = name;
this.tel = tel;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public int compareTo(Object object) {
return this.name.compareTo(((User)object).name);
}
}
package test.joeyta;
public class User implements Comparable {
private String name;
private String tel;
public User(){}
public User(String name, String tel){
this.name = name;
this.tel = tel;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public int compareTo(Object object) {
return this.name.compareTo(((User)object).name);
}
}
4 AutoSuggest.java
/** *//************** AutoSuggest.java ************************/
package test.joeyta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class AutoSuggest {
public List users;
public AutoSuggest(){
users = new ArrayList();
users.add(new User("Joeyta","123456"));
users.add(new User("陳大強","無電話"));
users.add(new User("李小強","太多電話"));
users.add(new User("Peter","23456"));
users.add(new User("Mary","34567"));
users.add(new User("Andy","45678"));
users.add(new User("Andrew","78900"));
users.add(new User("Anthory","89000"));
users.add(new User("jane","654321"));
}
public List getSuggestions(String sSuggestValue) {
System.out.println(sSuggestValue);
List returnList = new ArrayList();
if (sSuggestValue != null && !sSuggestValue.equals("")) {
for (Iterator iter = users.iterator(); iter.hasNext();) {
User user = (User) iter.next();
if(user.getName().toLowerCase().indexOf(sSuggestValue.toLowerCase()) >= 0){
returnList.add(user);
}
}
Collections.sort(returnList);
}
return returnList;
}
}
package test.joeyta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class AutoSuggest {
public List users;
public AutoSuggest(){
users = new ArrayList();
users.add(new User("Joeyta","123456"));
users.add(new User("陳大強","無電話"));
users.add(new User("李小強","太多電話"));
users.add(new User("Peter","23456"));
users.add(new User("Mary","34567"));
users.add(new User("Andy","45678"));
users.add(new User("Andrew","78900"));
users.add(new User("Anthory","89000"));
users.add(new User("jane","654321"));
}
public List getSuggestions(String sSuggestValue) {
System.out.println(sSuggestValue);
List returnList = new ArrayList();
if (sSuggestValue != null && !sSuggestValue.equals("")) {
for (Iterator iter = users.iterator(); iter.hasNext();) {
User user = (User) iter.next();
if(user.getName().toLowerCase().indexOf(sSuggestValue.toLowerCase()) >= 0){
returnList.add(user);
}
}
Collections.sort(returnList);
}
return returnList;
}
}
5 CharacterEncodingFilter.java
/** *//************** CharacterEncodingFilter.java ************/
package test.joeyta;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class CharacterEncodingFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected boolean ignore = true;
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (ignore (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
}
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;
}
protected String selectEncoding(ServletRequest request) {
return this.encoding;
}
}
package test.joeyta;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class CharacterEncodingFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected boolean ignore = true;
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (ignore (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
}
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;
}
protected String selectEncoding(ServletRequest request) {
return this.encoding;
}
}
6 autosuggest.css
/**//************** autosuggest.css ************/
div.suggestions {}{
background-color: #ffffff;
-moz-box-sizing:color: #0000f
div.suggestions {}{
background-color: #ffffff;
-moz-box-sizing:color: #0000f
发表评论
-
javascript 中数组使用方法
2009-10-29 13:27 655/* 由于javascript是一种无类型语言,所以一个数 ... -
ajax基础
2009-11-03 10:10 615XMLHTTPRequest---->JavaScrip ... -
ajax基础-jquery
2009-11-03 10:12 677//---------------------------- ... -
正则基础
2009-11-03 10:16 642<html> <script> ... -
可编辑的表格
2009-11-03 10:23 9021脚本jqueryedit.js //在页面装载时,让所有的t ... -
DWR-基本配置文件
2009-11-03 10:33 7051 dwr.xml <?xml version=&quo ... -
DWR-笔记
2009-11-03 10:36 713var xmlrequestXml; function cre ... -
DWR-util.js包工具方法
2009-11-03 10:41 1148util.js包含一些有用的函数function,用于在客户端 ... -
DWR-返回-参数为Map
2009-11-03 10:43 722方法1: fuction test{ tt.hello( ... -
DWR-返回-参数为集合
2009-11-03 10:54 711DWR中处理List调用返回JavaBean的java方法 4 ... -
正则基础2
2009-11-04 14:42 7711111-1234 re \d{5}(-\d{4})? ?指前 ... -
cookie.js
2009-11-04 15:42 733js读写cookie可以提高效率,现对代码作仔细说明,以备用: ... -
Event对象的属性
2009-11-29 21:37 692function MyAlert() { var msg=&q ... -
javascript DOM
2009-11-29 21:51 681<!------------------///事件处理 ... -
javascript语法_函数_对象_数组
2009-11-29 21:52 774<script language="javas ... -
事件显示声明
2009-11-29 21:55 743<script type=text/javascript ... -
LavaLamp mean
2009-12-06 23:18 778具有flash效果的菜单,基于jquery Download ... -
ajax 书签
2009-12-30 15:17 793框架: Yahoo UIProtoTypeJQueryOpen ... -
给Dreamweaver安装jQuery插件jQuery_API.mxp
2010-01-20 12:38 5106要让Dreamweaver支持jQuery自动提示代码功能,方 ... -
jQuery-强大的jQuery选择器 (详解)[转]
2010-01-21 11:48 9591. 基础选择器 Basics 名称 ...
相关推荐
在本场景中,我们利用DWR的功能来模拟一个控制台,实时将后台的日志输出到JSP(JavaServer Pages)页面上,从而提供一种直观的方式来监控应用程序的运行状态。 首先,理解DWR的工作原理至关重要。DWR的核心是异步...
在这个"模拟DWR写的小例子"中,我们将探讨DWR的基本原理、核心功能以及如何通过一个简单的实例来理解和应用DWR。 DWR的核心思想是提供了一种安全、高效的方法,使得JavaScript可以调用服务器上的Java方法,就像是...
在本项目"**DWR操作数据库模拟实现Google搜索效果**"中,我们将探讨如何利用DWR技术来创建一个类似Google搜索的体验。这个项目的核心目标是通过用户在前端输入关键词,实时从后台数据库中检索匹配的信息,并在页面上...
**DWR(Direct Web Remoting)**是一种Java技术,它允许在Web应用程序中实现JavaScript与服务器端Java对象的直接远程调用(RPC)。通过DWR,开发者可以轻松地创建动态、交互性强的Web界面,无需处理复杂的AJAX...
dwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwrdwr dwr
在这个实例中,“DWR实现Google自动提示功能”是利用DWR框架来构建一个类似于Google搜索框的自动提示功能,用户在输入框中输入时,后台会实时地根据输入内容提供相关的建议,无需页面刷新。 一、DWR框架详解: DWR...
本示例主要展示了如何使用纯JSP和Direct Web Remoting (DWR)技术来构建一个功能丰富的用户界面,其中包括三级联动下拉选择菜单、无刷新联动、用户存在性判断以及模拟Google搜索效果的功能。DWR是一种JavaScript库,...
DWR(Direct Web Remoting)是一种Java库,它允许JavaScript在客户端与服务器端进行直接的交互,从而实现在Web应用程序中的Ajax功能。DWR的主要目标是简化前后端的数据交换,提高用户体验,使得Web应用能够像桌面...
DWR (Direct Web Remoting) 是一种开源Java技术,它允许Web应用程序在浏览器和服务器之间进行实时、双向通信,使得JavaScript可以直接调用服务器端的Java方法,极大地简化了客户端和服务器端的数据交换。本笔记将...
1、 导入dwr.jar包 2、 在web.xml中配置dwr,如下: <!-- 配置DWR --> <servlet-name>dwr-invoker org.directwebremoting.servlet.DwrServlet <init-param> <param-name>debug</param-name> ...
DWR (Direct Web Remoting) 是一个开源的Java库,它允许JavaScript在浏览器端与服务器端的Java对象进行交互,实现动态的Web应用。DWR简化了AJAX(Asynchronous JavaScript and XML)的开发,使得开发者可以像调用...
3. **dwr-gwt.jar**(如果适用):用于与Google Web Toolkit (GWT)的集成。 4. **其他依赖的jar包**:可能包括一些第三方库,如Spring、Servlet API等,具体取决于DWR版本和配置。 集成DWR时,开发人员需要在Web...
**DWR(Direct Web Remoting)**是一种Java技术,它允许Web应用程序在客户端与服务器之间进行实时通信,而无需刷新整个页面。通过DWR,我们可以使用JavaScript直接调用服务器端的Java方法,实现Ajax(Asynchronous ...
本实例是用SSH+DWR+Oracle10g做的模拟Goolge搜索的守完整实例 内容包括: 1、给每行绑定一个鼠标移上和移走事件 onmouseover onmouseout 2、焦点如果从文本框转移动显示的层中 设置了文本框失去焦点事件,目的是让...
DWR(Direct Web Remoting)是一种Java库,用于在Web应用程序中实现实时的JavaScript到服务器端Java对象的通信。这个技术允许开发者在浏览器中直接调用服务器端的方法,极大地简化了AJAX(Asynchronous JavaScript ...
这个压缩包包含了DWR的三个主要版本:DWR1.0、DWR2.0和DWR3.0的jar包,这些jar包是运行DWR应用的核心组件。 DWR1.0: DWR1.0是DWR项目的早期版本,主要目标是简化Web应用中的异步通信。在这个版本中,DWR提供了一个...
在"struts+jdbc+dwr 实现googlemap功能"的项目中,开发者利用这些技术构建了一个功能,当用户点击地图上的特定图标时,会显示相关的公司信息,如公司电话和名称。以下是对这个项目的详细解释: 首先,Struts框架在...
Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr入门操作手册Dwr...
除了基本的远程方法调用,DWR还支持批量调用、异步处理、CORS支持、以及对AJAX事件的模拟等高级特性。熟悉这些特性能帮助你构建更复杂的交互式Web应用。 总之,DWR为开发实时Web应用提供了一种简单而强大的工具。...