[英]wicket : passing json object from javascript to java
how can we pass JSON object from Javascript(Client) to Java(Server) ? 我们如何将JSON对象从Javascript(Client)传递到Java(Server)?
i want to access that JSON object in my Java method 我想在我的Java方法中访问该JSON对象
You can execute any JavaScript by the method: 您可以通过以下方法执行任何JavaScript:
http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/AjaxRequestTarget.html#appendJavaScript%28java.lang.CharSequence%29 http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/AjaxRequestTarget.html#appendJavaScript%28java.lang.CharSequence%29
AjaxRequestTarget is the result object of a button and a lot of other components. AjaxRequestTarget是按钮和许多其他组件的结果对象。
To receive the JSON on the server side, you will not find a method in Wicket. 要在服务器端接收JSON,您将无法在Wicket中找到方法。 I think this JSON receiver you will need to code on your own using standard tools like Servlet. 我认为您需要使用Servlet等标准工具自行编写此JSON接收器代码。 GSON is a great Java library to parse JSON to and from Java objects. GSON是一个很棒的Java库,用于在Java对象之间解析JSON。
Sebastian 塞巴斯蒂安
You can send a JSON object to a Wicket AJAX behavior/component using the parameters and the JavaScript function described here: https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax However this works with Wicket 6.0. 您可以使用此处描述的参数和JavaScript函数将JSON对象发送到Wicket AJAX行为/组件: https : //cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax但是,此功能可用于Wicket 6.0。 What version are you using? 您使用什么版本?
Try to use Seam remoting. 尝试使用Seam远程处理。 It works pretty well. 效果很好。
you can find an example here: http://tutslink.blogspot.com/2012/10/jsf-tutorials-using-seam-3-remoting.html 您可以在此处找到示例: http : //tutslink.blogspot.com/2012/10/jsf-tutorials-using-seam-3-remoting.html
You just instantiate your been on client side and execute it's method passing JSON as argument to it. 您只需实例化客户端,然后执行将JSON作为参数传递给它的方法即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.