Posted on 2011-04-24 10:49
哈希 阅读(115)
评论(0) 编辑 收藏 所属分类:
java 常用框架
我个人的理解啊:
dwr其实就是一个servlet包,它已经实现了功能,我们呢只需要调用就可以啊,关键在配置:
好了,二二话不说,看啥叫犀利吧:
第一步: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>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
第二步:dwr配置(
先倒入jar包dwr.jar)
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
<allow>
<create creator="new" javascript="us">
<param name="class" value="org.man.prj.Hello" />
</create>
<create creator="new" javascript="Students">
<param name="class" value="org.man.prj.Students"/>
</create>
</allow>
</dwr>
第三步:写java代码
根据你的需要了啊
第四步:index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<script src="/mydwr/dwr/interface/Students.js"></script>
<script src="/mydwr/dwr/engine.js"></script>
<script src="/mydwr/dwr/util.js"></script>
<script type="text/javascript">
var dwr_callback = function(data){
alert(data);
}
</script>
<select name="classid" id="classid" onchange="javascript:update2();"></select>
<body>
This is my JSP page. <br>
<input type="button" value="invoke" onclick="us.hellodwr(dwr_callback)" />
</body>
好了这样就可以使用dwr了,很方便哦!
不懂的话就和他们联系!QQ群:110703194