Vaadin - 使用 POST 在浏览器中打开 URL

发布于 2025-01-13 19:38:41 字数 99 浏览 3 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后知后觉 2025-01-20 19:38:42

实际上,作为 POST 请求导航到页面意味着应该提交“传统”

。 Vaadin 不提供以这种方式提交表单的高级支持,但您可以使用低级 API(例如 new Element("form"))为表单创建服务器端表示形式本身,配置它应该如何工作(例如定义操作)。相应地,您还可以使用 new Element("input") 创建隐藏的输入字段,其中包含要在正文中提交的数据(假设应将其发布为 application/x-www -form-urlencoded),然后通过常规 HTML 按钮或使用 formElement.callJsFunction("submit") 通过 JS 提交表单。

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 as new Element("form") to create a server-side representation for the form itself, configure how it should work (e.g. defining the action). Correspondingly, you can also use new Element("input") to create hidden input fields with the data you want to submit in the body (assuming it should be posted as application/x-www-form-urlencoded) and then submitting the form either through regular HTML button or through JS using formElement.callJsFunction("submit").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文