通过jsp url调用servlet中的函数

发布于 2024-12-21 15:54:10 字数 188 浏览 0 评论 0原文

我正在尝试使用 jsp 文件 (index.jsp) 中的超链接对我调用 servlet(index.java) 的字段进行排序。 当用户单击标题(即“ID”)时,应从 servlet 调用 sort() 函数并进行排序。 附加信息:我从index.java中的数据库收集元素,并使用requestdispatcher对象将其打印在index.jsp页面上。

I'm trying to sort a field for which i call a servlet(index.java) using a hyperlink from my jsp file (index.jsp)..
When the user clicks the heading (which is "ID") the sort() function should be called from the servlet and should get sorted.
additional info: i collect the elements from the database in index.java and print it on the index.jsp page using the requestdispatcher object.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

泡沫很甜 2024-12-28 15:54:11

据我所知,您不能直接从 JSP 调用 servlet 的方法。
您可以做的一件事是您可以调用一个 servlet,该 servlet 在其 service() 方法中为您进行排序并将相同的结构数据(但现在处于排序模式)返回到 JSP。

您可以使用 AJAX(仅刷新该页面的一部分)或刷新整个页面来调用此方法。

According to me you can not call a method of the servlet directly from the JSP.
One thing you can do is you can call a servlet which in its service() method do the sorting for you and returns the same structure data (but now in sorted mode) to the JSP.

You can call this using AJAX (which refreshes the part of that page only) or by refreshing the the whole page.

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