从java返回一个值对象给flex,它包含两个字符串数组作为它的属性
我用 Flex 来构建前端。我对从java发送两个字符串数组到flex有一个疑问。
我怎样才能做到这一点?
例如,我有一个如下定义的值对象。
class Test
{
String value1[]={"1","2","3"};
String value2[]={"narendra","mani","suresh","kane"};
//Getter and setters goes here
}
有人可以帮我解决这个问题吗?
谢谢,
纳伦德拉
I amusing Flex for front end building. I have one doubt regarding sending two array of strings from java to flex.
How can I do that?
For example I have a value object defined like below.
class Test
{
String value1[]={"1","2","3"};
String value2[]={"narendra","mani","suresh","kane"};
//Getter and setters goes here
}
Can any one help me on this?
Thanks,
Narendra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上是一个你希望 Flex 如何与 Java 层通信的问题,我认为最接近交钥匙解决方案的是使用服务器上的 BlazeDS jar 来进行 Java DTO 和 Actionscript DTO 之间的 ActionScript 消息格式转换,基本上它的工作原理是您在 Java 端进行编码,然后您可以让它生成 Java 等效的 DTO,这些 DTO 将用元数据标记,因此当 Java 对象被序列化并通过网络发送时,客户端将它们作为类型化对象。
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS
或者,您可以使用 JSP 将数据公开为 XML 来生成 XML,然后只需使用对 JSP 的 HTTPService 调用来获取 XML 数据,然后由于 AS3 使用 E4X 将 XML 解析为 AS3 对象非常容易,有很多示例执行此操作只需搜索 e4x AS3 的示例。
希望这有帮助,
肖恩
This is really a matter of how do you want Flex to communicate with your Java layer, I think the closest to a turn key solution to this is using the BlazeDS jar on the server to do the ActionScript Message Format conversion between Java DTOs and Actionscript DTOs, basically how it works is you code up the Java side then you can have it generate the Java equivalent DTOs that will be tagged with Metadata so when the Java objects are serialized and sent across the wire the client has them as typed objects.
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS
Alternatively you could expose the data as XML using a JSP to generate the XML then just using an HTTPService call to the JSP to get the XML data then since AS3 makes use of E4X parsing the XML into AS3 objects is very easy, lots of examples of doing this just search for e4x AS3 for examples.
Hope this helps,
Shaun