如何从 Stripes ActionBean 获取 javascript 的返回值?
我正在尝试使用 Google 的 Channel API 构建 2 人游戏会话。我正在使用 JavaScript 函数开始打开通道,并且我有一个 Stripes ActionBean,可以打开通道并为特定用户获取新的令牌。
如何从 JavaScript 调用 ActionBean 并从 ActionBean 获取“字符串令牌”? ${actionBean.token} 在 .js 文件中不起作用。
PS:我对这些语言很陌生,希望您能投入时间和精力来回答我的问题。谢谢 !
编辑:谢谢!我已阅读建议的链接,并且对 JavaScriptResolution 感到很兴奋。如何在 javascript 中接收 JavaScriptResolution?任何人都可以提供一个代码片段吗?
I am attempting to use Google's Channel API to construct a 2-player game session. I am using a JavaScript function to start opening the channel, and I have a Stripes ActionBean that opens the channel and obtains a new Token for the specific user.
How do I call the ActionBean from JavaScript and get the "String token" from the ActionBean? ${actionBean.token} did not work in the .js file.
PS: I am new to these languages and would appreciate the time and effort invested in answering my question. Thanks !
Edit: Thank you ! I have read the proposed links and I am excited about the JavaScriptResolution. How do I receive the JavaScriptResolution in javascript? Can anyone kindly provide a code snippet perhaps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您在使用 Javascript 生成页面的 actionBean 中生成 Javascript,否则 ${actionBean.token} 将不起作用。在这种情况下,您需要 Ajax,您需要使用 Javascript 发出 http 请求。您可能想看一下这个 Stripes Ajax 示例:
Stripes Ajax 示例
您也可以想要使用 JavaScriptResolution 将对象从actionBean返回到Javascript,请参阅示例代码:
Amis JavaScriptResolution 示例
Unless you are generating the Javascript in the actionBean that generates the page with the Javascript, the ${actionBean.token} will not work. In that case you need Ajax, you need to make the http request in Javascript. You might want to take a look at this Stripes Ajax example:
Stripes Ajax Example
You might also want to use a JavaScriptResolution to return objects from an actionBean to Javascript, see example code:
Amis JavaScriptResolution Example