[英]How to call servlet doPost() method from browser
I'm new to servlet programming and I have written a simple servlet running on Apache Tomcat 9.0.39.我是 servlet 编程的新手,我编写了一个在 Apache Tomcat 9.0.39 上运行的简单 servlet。 The logic in the
doPost()
and the doGet()
methods are different from each other. doPost()
和doGet()
方法中的逻辑彼此不同。 I can simply invoke the doGet()
as follow and receive an accurate response from the servlet:我可以简单地调用
doGet()
并从 servlet 接收准确的响应:
localhost:8080/myservlet/load?id="4"
The doPost()
method is sending two parameters "author" and "title" to the servlet to store. doPost()
方法将两个参数“author”和“title”发送到 servlet 进行存储。 Ultimately, I'd like to keep this simple and not to develop an Html form to submit the values for the "author"
and the "title"
to the servlet.最后,我想保持这个简单,而不是开发一个 Html 表单来将
"author"
和"title"
的值提交给 servlet。 Is there a way I can invoke the doPost()
from the browser as I had for the doGet()
method?有没有办法像我对
doGet()
方法那样从浏览器调用doPost()
?
Thanks in advance.提前致谢。
Actually it does not matter if it is servlet or not.实际上它是否是servlet并不重要。 The problem area is regarding Http protocol.
问题区域与 Http 协议有关。 From your browser you can send post request, of course.
当然,您可以从浏览器发送发布请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.