Servlet + Jsp问题
我有一个 JSP 页面,我想从其中的 onClick 执行一个 servlet 页面。任何人都可以帮助我,这怎么可能?
I have a JSP page, from where onClick I want to execute a servlet page. Can anybody help me, how can it possible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
或者
Google 搜索
request.sendRedirect("URL");
和request.getRequestDispatcher("URL");
之间的区别or
Google search for the difference between
request.sendRedirect("URL");
andrequest.getRequestDispatcher("URL");
如果您不想重新加载当前页面或使用
window.location.href
属性执行重定向,则可以使用 AJAX 调用来调用 servlet。如果您想向服务器发送一些值,您可以在 AJAX 请求正文中发送它们,或者如果您决定重定向,则将它们作为查询字符串参数发送。You could use an AJAX call to invoke the servlet if you don't want to reload the current page or perform a redirect using the
window.location.href
property. If you want to send some values to the server you could send them in the AJAX request body or as query string parameters if you decide to redirect.您需要一个带有单个按钮的表单,并将表单发送到 servlet
,或者您可以使用简单的
单击一些文本
或您的 图像下的链接Servlet必须在web.xml中描述或者通过注解的方式才能被调用。
You need a form with single button, and send form to the servlet
or you can use simple
<a href="yourServlet">some text to be clicked</a>
or link under imageyour Servlet must be described in web.xml or by annotation to let it be called.