-
dwr 上使用json10
最近使用dwr传递json数据,dwr说是支持dojo,但是不明白这里的东西。希望有懂这方面的牛人不吝赐教,不胜感激!
这是
dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "http://getahead.org/dwr/dwr30.dtd">
<dwr>
<allow>
<create creator="new" javascript="Demo">
<param name="class" value="mlt.test.Demo" />
</create>
<convert match="mlt.test.Demo" converter="bean" />
</allow>
</dwr>
下面是一个测试页面
<html>
<head>
<script type='text/javascript' src='/zxdy/dwr/interface/Demo.js'>
</script>
<script type='text/javascript' src='/zxdy/dwr/engine.js'>
</script>
<script type='text/javascript' src='/zxdy/dwr/util.js'>
</script>
<script type="text/javascript">
var services = new dojox.rpc.Service( {
target : "../dwr/jsonrpc",
transport : "POST",
envelope : "JSON-RPC-1.0",
contentType : "application/json",
services : {
"Demo.sayHello" : {
returns : {
"type" : "string"
},
parameters : [ {
"type" : "string"
} ]
}
}
});
function update() {
var name = dojo.byId("demoName").value;
var deferred = services.Demo.sayHello(name);
deferred.addCallback(function(result) {
dojo.byId("demoReply").innerHTML = result;
});
}
</script>
</head>
<body>
<p>
Name:
<input type="text" id="demoName" />
<input value="Send" type="button" onclick="update()" />
<br />
Reply:
<span id="demoReply"></span>
</p>
</body>
</html>
下面是
web.xml的配置文件
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class><!--
This should NEVER be present in live -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<!-- Remove this unless you want to use active reverse ajax -->
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- By default DWR creates application scope objects when they are first
used. This creates them when the app-server is started -->
<init-param>
<param-name>initApplicationScopeCreatorsAtStartup</param-name>
<param-value>true</param-value>
</init-param>
<!-- WARNING: allowing JSON-RPC connections bypasses much of the security
protection that DWR gives you. Take this out if security is important -->
<init-param>
<param-name>jsonRpcEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- WARNING: allowing JSONP connections bypasses much of the security
protection that DWR gives you. Take this out if security is important -->
<init-param>
<param-name>jsonpEnabled</param-name>
<param-value>true</param-value>
</init-param>
<!-- data: URLs are good for small images, but are slower, and could OOM
for larger images. Leave this out (or keep 'false') for anything but small
images -->
<init-param>
<param-name>preferDataUrlSchema</param-name>
<param-value>false</param-value>
</init-param>
<!-- This enables full streaming mode. It's probably better to leave this
out if you are running across the Internet -->
<init-param>
<param-name>maxWaitAfterWrite</param-name>
<param-value>-1</param-value>
</init-param>
<!-- For more information on these parameters, see: - http://getahead.org/dwr/server/servlet
- http://getahead.org/dwr/reverse-ajax/configuration -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
上面的target 这个 这个在tomcat上跑 跑不通,javascript中的一个 还有这个target后面的 ../dwr/jsonrpc 是哪个jsonrpc 是怎么搞的,谁能给讲解下这些东西。搞不懂。
2012年2月27日 21:08
目前还没有答案
相关推荐
dwr框架例子返回json数据,带dwr包
源码工程奉上,这里是SQLSERVER2005的,以前一个老版本2000的dwr分页,可在地址: http://download.csdn.net/source/1413703 下载。保证质量。
天气预报,城市select联动,dwr,json 全国各省名称: http://www.weather.com.cn/data/list3/city.xml 全国城市: http://www.weather.com.cn/data/city3jdata/china.html 获得各省城市清单: ...获得各市城市清单: ...
使用EXT的EditorGrid,实现前台页面对数据直接进行增删改查操作。...例子中使用了DWR和JSON.含MySQL数据库脚本,并已加入Log4j日志记录。本例详细讲解可以参见:http://www.cshopetech.com/showtopic-239.aspx
json jquery dwr 个人测试
内含 ext+dwr+freemark+jasperreort+ireport+echance+oscache+velocite等技术 展示例子:http://zz563143188.iteye.com/blog/1462413 若要下载chm格式请到http://user.qzone.qq.com/563143188 程序源码下载地址10MB...
网站框架搭建,涉及struts2+jquery+json、dwr、log日志、过滤器、拦截器。
NULL 博文链接:https://haiyangyiba.iteye.com/blog/683634
理解DWR(Direct Web Remote)的使用方法 - 请参考《DWR介绍》 理解JSON(JavaScript Object Notation)数据格式 - 可参考http://www.json.org/json-zh.html
主要利用hibernate3.0+struts2.0 +dwr1+spring框架
ext+json+dwr+spring+hibernate整合项目实例与相关资源
ext+Json+dwr+spring+hibernate整合项目实例与资源
三大框架框架整合,结合最新extjs3.0技术,以及json作为数据交换器,dwr框架的无刷新实现,不可多得的动态树实现列子,千万不要错过哟!
web服务的ajax请求数据直接调用javaDAO类返回JSON数据。取值方便。快捷
ssh实验代码 dwr ext3 struts2 spring3 json 分布式ehcahe等等实验都有,某些做法忘记了,可以在这里加上以做备查,jar文件均包括了
默认的 json 加载器,'url' 属性表示要获取 json 数据的远程 URL。 当使用 DWR 加载器时,我们应分配一个函数给 'url' 属性来从 DWR 获取数据
spring mvc的json和xml视图,dwr及静态资源等不同种类url整合,对应博客教程地址: http://blog.csdn.net/qgmzzn1/article/details/8465969