有办法通过AJAX从客户端JavaScript代码调用服务器端Groovy对象方法吗?

时间:2022-04-01 16:00:35

There is DWR which satisfies my needs in Java. I'm interested if there is any Groovier way to do the same thing - with convention over configuration, dynamic method invokation, etc.

有DWR可以满足我在Java中的需要。我感兴趣的是是否有更规范的方法来做同样的事情——约定优于配置、动态方法调用等等。

2 个解决方案

#1


3  

I don't think there is such framework at the moment. In the mean time, you may try using Groovy objects with DWR.

我认为目前还没有这样的框架。与此同时,您可以尝试在DWR中使用Groovy对象。

Or if you're going to use Grails, you may have a look at Grails DWR plugin: http://grails.org/DWR+Plugin

或者如果你打算使用Grails,你可以看看Grails DWR插件:http://grails.org/DWR+ plugin

And this one is an unofficial update for DWR 3: http://www.nabble.com/Updated-DWR-Plugin-for-DWR-3-td21421849.html

而这个是DWR 3的非官方更新:http://www.nabble.com/updateddwr-plugin -for- dwr-3-t21421849.html。

#2


1  

I would recommend looking into Grails. The content negotiation feature can be used to return Groovy objects from grails controllers in different formats (xml, json, etc.) and you can consume the JSON on the client side. It literally just takes a few lines of code from a grails controller to return HTML, JSON and XML representations of your objects.

我建议研究Grails。内容协商特性可以用于从grails控制器返回不同格式(xml、json等)的Groovy对象,您可以在客户端使用json。它只需要从grails控制器中提取几行代码来返回对象的HTML、JSON和XML表示。

#1


3  

I don't think there is such framework at the moment. In the mean time, you may try using Groovy objects with DWR.

我认为目前还没有这样的框架。与此同时,您可以尝试在DWR中使用Groovy对象。

Or if you're going to use Grails, you may have a look at Grails DWR plugin: http://grails.org/DWR+Plugin

或者如果你打算使用Grails,你可以看看Grails DWR插件:http://grails.org/DWR+ plugin

And this one is an unofficial update for DWR 3: http://www.nabble.com/Updated-DWR-Plugin-for-DWR-3-td21421849.html

而这个是DWR 3的非官方更新:http://www.nabble.com/updateddwr-plugin -for- dwr-3-t21421849.html。

#2


1  

I would recommend looking into Grails. The content negotiation feature can be used to return Groovy objects from grails controllers in different formats (xml, json, etc.) and you can consume the JSON on the client side. It literally just takes a few lines of code from a grails controller to return HTML, JSON and XML representations of your objects.

我建议研究Grails。内容协商特性可以用于从grails控制器返回不同格式(xml、json等)的Groovy对象,您可以在客户端使用json。它只需要从grails控制器中提取几行代码来返回对象的HTML、JSON和XML表示。