使用 DWR 的示例程序
我正在尝试编写一个带有直接网络远程处理的示例程序。访问网站 http://directwebremoting.org/ 有一些基本问题。请帮助我
尝试该程序 http://directwebremoting.org/dwr-demo/simple /text.html
- 在哪里保存 html 和 javascript 代码以及用什么名称???
- 他们说要包含一些 2 个脚本(engine.js 和 util.js)。我应该在哪一页中包含这两个。
- 他们也给了一个java代码,现在保存在哪里???
I am trying to write a sample program with direct web remoting. went through the site http://directwebremoting.org/ have some basic questions. please help me
what to try the program http://directwebremoting.org/dwr-demo/simple/text.html
- where to save the html and javascript code and with what name???
- they say to include some 2 scripts (engine.js and util.js). in which page i should include these two.
- they have given a java code also, where to save this now???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要开始使用 DWR,您必须在以下位置创建 dwr.xml 文件:
添加 dwr.jar 文件到
如果未创建 lib 文件夹,则创建它。
您必须知道,DWR 使用 servlet 类来发挥作用,因此您必须声明它们必须如何工作。您必须修改 web.xml 文件以告诉 DWR 它是一个 servlet。
您可以测试您的 DWR 配置,以检查
yourapp 是否是您的应用程序的名称,port 是否是分配的端口号。
现在您必须创建一个与 DWR 和 JSP 页面交互的类控制器。像这样的
com.dwr.test.MyController
你必须告诉 DWR 这是一个控制器,所以在你的 dwr.xml 文件中你必须写
检查
javascript="mycontroller"
这就是您从 JSP 页面调用 java 类控制器的方式
现在您已经与 App 控制器和 DWR 建立了控制器连接。
稍后,您必须告诉 JSP 页面使用什么控制器。
我以index.jsp为例,
这个东西是如何工作的?两个脚本行(util an engine)对于DWR至关重要,这是DWR工作的主要场景。
第三行是您最近在 drw.xml 文件中声明的控制器的名称。您不需要创建该文件,DWR 负责创建该文件。
现在您可以将您的方法与任何 HTML 控制器、javascript 函数或其他任何东西一起使用,
以了解更多方法、传递参数参数我建议您访问 DWR 的网页
http://directwebremoting.org/dwr/index.html
To start with DWR you have to create your dwr.xml file at
add dwr.jar file to
if lib folder is not created then create it.
And how you must kwno, DWR uses servlet classs to be functional, so you have to declare them how must work. You have to modify your web.xml file to tell DWR that it is a servlet.
You can test you DWR configuration going to
check that yourapp is the name of your app and port is the number of the assigned port.
Well now you have to create a class controller that interactues with DWR and your JSP pages. Something like this
com.dwr.test.MyController
you have to tell DWR that this is a controller, so in your dwr.xml file you have to write
Check that
javascript="mycontroller"
is how you are going to call your java class controller from your JSP page
Now you have a controller connection with your App controller and DWR.
Later, you have to tell to your JSP page what controller use.
I have index.jsp as an example
how this stuff works ? the two script lines (util an engine) are vital for DWR, this is the main scenario that DWR uses to work.
And the third line is the name name of your Controller that you recently declared in your drw.xml file. You don't need to create this files, DWR is responsible of the creation of this files.
now you can use your method with any HTML controller, javascript function or anything else
to know more methods, passing parameters arguments I recommend you visit DWR's web page
http://directwebremoting.org/dwr/index.html
请参阅这些链接
使用 DWR 使 AJAX 变得简单
DWR 入门
Refer to these links
AJAX made simple with DWR
Getting Started with DWR