RequestDispatcher是否会转发原始请求的HTTP方法? [英] Does a RequestDispatcher forward maintain the original request's HTTP method?

查看:65
本文介绍了RequestDispatcher是否会转发原始请求的HTTP方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用RequestDispatcher拦截请求,然后将请求转发到另一个servlet-像这样:

I want to intercept a request using the RequestDispatcher, and then I want to forward the request along to another servlet -- something like this:

RequestDispatcher dispatcher = request.getRequestDispatcher("/servlet/some.ThirdPartyServlet" + "?" + "param_name=" + "somevalue");
dispatcher.forward(request, response);

如果传入的请求是POST,请求分派器将采用我的新参数,并将其包含在消息正文中,还是现在转发成为GET?

If the incoming request were a POST, will the request dispatcher take my new parameters, and include them in the message body, or does this forward now become a GET?

推荐答案

它保留原始请求,而不更改它.

It retains the original request, without changing it.

因此,如果它是POST,它将保留为POST.

So, it will remain POST if it was POST.

这篇关于RequestDispatcher是否会转发原始请求的HTTP方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆