servlet 可以调用方法并传递从 Web 请求中提取的值
我有一个关于 Servlet 如何调用方法并传递从 Web 请求中提取的值的问题。在Web请求中处理Web请求的场景,我需要调用一个方法并传入从Web请求中提取的值。当该方法返回值时,在 Web 响应中发送该值。谢谢
i have a question on how a servlet call a method and pass the value extracted from the web request. A scenario in which a web request is processed in a web request, i need to call a method and pass in the values extracted from the web request. When the method returns a value, send the value in the web response. thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,你需要这样的东西:
If I understand you right you need something like this:
当请求来自浏览器时,它将首先读取web.xml并调用适当的servlet的服务方法。然后服务方法根据请求决定调用doPost或doGet方法。一旦获得参数,您需要创建 requestDispatcher 对象并调用转发方法来发送您的响应。
When request comes from browser, it will first read web.xml and call service method of appropriate servlet. Then service method decide to call doPost or doGet method on the basis of request. Once you get parameter , you need to create object of requestDispatcher and call forward method which will send your response.