简体   繁体   English

RequestDispatcher的

[英]RequestDispatcher

request.getRequestDispatcher("https://app.inpostlinks.com/login").forward(request, response);

I want to forward the request to the foreign URL like https://app.inpostlinks.com/login , not residing on the container where the servlet resides. 我想将请求转发到外部URL,如https://app.inpostlinks.com/login ,而不是驻留在servlet所在的容器上。

It's not getting forwarded. 它没有被转发。 Are there any solutions on the above scenario? 在上述场景中是否有任何解决方案?

Forwarding is for passing say a servlets request and response to a JSP to do the presentation of the result of some business logic. 转发是为了传递一个servlet请求和对JSP的响应来表示某些业务逻辑的结果。

If you want to pass the user to a different website, you need to do a "redirect" instead of a "forward", ie get the server to return a 301 code and a location: 如果要将用户传递到其他网站,则需要执行“重定向”而不是“转发”,即让服务器返回301代码和位置:

response.sendRedirect(url);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM