jQuery AJAX调用Java方法 [英] jQuery AJAX to call Java method

查看:501
本文介绍了jQuery AJAX调用Java方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery AJAX,我们可以调用特定的JAVA方法(例如,来自Action类)

Using jQuery AJAX, can we call a specific JAVA method (e.g. From an Action class)

来自该Java方法的返回数据将用于填充一些HTML代码。

The returned data from that Java method would be used to fill in some HTML code.

请告诉我是否可以使用jQuery轻松完成(就像在DWR中一样)..对于HTML中的多个数据点,我们是否需要发出多个AJAX请求?

Please let me know if this can be done easily using jQuery (like it does in DWR)..Also for multiple data points in HTML, do we need to make multple AJAX requests?

推荐答案

简单的答案是你将ajax调用映射到url,这些url在转向映射到方法在你的java代码中。 Ajax - > URI映射发生在客户端(您使用的js框架,以及URI - >特定处理程序映射在java应用程序中发生)

The simple answer is you map your ajax calls to urls, which are in turned map to methods in your java code. The Ajax -> URI mapping happens on the client side (which ever js framework you are using, and the URI -> specific handler mapping happens within the java application)

什么你在使用java框架吗?关于如何做到这一点,应该有非常清晰简单的文档。对于标准的Java EE映射(意味着你没有使用像Spring或Roo这样的任何框架)我在google上发现了这个: http://javapapers.com/servlet/what-is-servlet-mapping/

What java framework are you using? There should be very clear and simple documentation on how to do this. For standard Java EE mappings (meaning you are not using any frameworks like Spring or Roo) I found this on google: http://javapapers.com/servlet/what-is-servlet-mapping/

对于HTML中的多个数据点我假设您正在谈论拥有html更新的多个部分。您可以使用多个请求执行此操作,或者您可以使用一个请求执行此操作。如果您执行后者,服务器需要返回适当更新dom所需的所有数据。

"For multiple data points in HTML" I assume you are talking about having multiple parts of the html update. You can do this with multiple requests, or you can do it with one request. If you do the latter, the server needs to return all the data you need to update the dom appropriately.

这篇关于jQuery AJAX调用Java方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆