本文介绍了如何使用HttpClient处理post方法中的重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我将xml文件发布到服务器,但有时服务器将发回302然后重定向。

In My App , I POST a xml file to the server , but sometimes the server will send back 302 and then redirect .

但是,重定向后,方法变为GET,而不是POST,并且我在xml文件中的数据无法传送到服务器。

However , after the redirecting the method become GET , not POST, and my data in xml file can't deliver to server.

最后我得到的状态代码是404。

And finally the status code I got is 404.

有没有办法自行处理重定向?重定向发生时我可以做些什么吗?

Is there some way to process the redirect by myself ? Can I do something when the redirecting is happening?

任何人都可以提供帮助吗? THX。!

Anyone can help? THX.!

推荐答案

来自:

您确定您的服务器没有使用''成语?

Are you sure your server isn't using the 'POST, redirect, GET' idiom?

你可以。例如:

_httpClient = new DefaultHttpClient();
_httpClient.getParams().setParameter(
    ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);

这篇关于如何使用HttpClient处理post方法中的重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 20:07