Vaadin - 使用 POST 在浏览器中打开 URL
在我的 Vaadin 14 应用程序中,我想在用户单击按钮时打开具有适当参数的网站。资源需要参数作为 post 请求的正文。如何通过 post 请求在 Vaadin 中打开新 URL?
In my Vaadin 14 application, I want to open a website with the appropriate parameters when the user clicks on a button. The resource needs the parameters as the body of the post request. How can I open a new URL in Vaadin with a post request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,作为 POST 请求导航到页面意味着应该提交“传统”
Navigating to a page as a POST request does in practice mean that a "traditional"
<form>
should be submitted. Vaadin doesn't have high-level support for submitting forms in that way, but you can use low-level APIs such asnew Element("form")
to create a server-side representation for the form itself, configure how it should work (e.g. defining theaction
). Correspondingly, you can also usenew Element("input")
to create hidden input fields with the data you want to submit in the body (assuming it should be posted asapplication/x-www-form-urlencoded
) and then submitting the form either through regular HTML button or through JS usingformElement.callJsFunction("submit")
.