android发布问题,为什么我收到“主机没有路由" [英] android post issue, why I receive "No route to host"

查看:97
本文介绍了android发布问题,为什么我收到“主机没有路由"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我吗?呼叫HttpResponse response = client.execute(request);

Anybody can help me? When calling HttpResponse response = client.execute(request);

它抛出一个IOException,其中显示没有主机路由" .

It throws an IOException, which shows "No route to host".

HttpClient client = new DefaultHttpClient();   
HttpPost request = new HttpPost(urlstr.toString());             

List<NameValuePair> postParams = new ArrayList<NameValuePair>();  
postParams.add(new BasicNameValuePair("Login_User_Name", namestr));  
postParams.add(new BasicNameValuePair("Login_User_Password", passwordstr));          
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParams, HTTP.UTF_8);  
request.setEntity(formEntity);  
HttpResponse response = client.execute(request); 

我的网络源代码在下面

<div class="S-Login" id="S-Login">
    <div class="h" JNetDriftBar="title">
        <span>
                    </span>
    </div>
    <div class="lt" Lge="Login_User_Name"></div>
    <div class="ln">
        <div class="N-Ipt">
            <div class="Nir"></div>
            <div class="Nil"></div>
            <div class="Nic">
                <input type="text" id="Login_User_Name" JNetDriftBar=":focus" value="" maxlength="40" />
            </div>
        </div>
    </div>
    <div class="lt" Lge="Login_User_Password"></div>
    <div class="ln">
        <div class="N-Ipt">
            <div class="Nir"></div>
            <div class="Nil"></div>
            <div class="Nic">
                <input type="password" id="Login_User_Password" value="" maxlength="40" />
            </div>
        </div>
    </div>
    <div class="lt" Lge="Login_Language"></div>
    <div class="ln" style="text-align:left;">
        <div class="N-Select">
            <div class="N-Ipt">
                <div class="Nir"></div>
                <div class="Nil"></div>
                <div class="Nic">
                    <input type="text" readonly="readonly" id="Login_Language" value="" />
                </div>
            </div>
            <div class="NOpt Nc Lg" id="Login-allLanCot">

            </div>
        </div>
    </div>
    <div class="lt"></div>
    <div class="ln">
        <a href="javascript:;" hidefocus="true" class="N-Btn-1" onmousedown="$$.md(this,'N-Btn-1dw',event);" onmouseup="$$.mu(this,'N-Btn-1dw',event);" Lge="Login_Enter" onclick="Entry.submit();"></a>
    </div>
</div>

推荐答案

URL中的域名无效(不存在),没有网络连接或者DNS服务器设置不正确.确认您可以在Android浏览器中浏览到该URL.

Either the domain name in the URL is invalid (does not exist), you have no network connection, or your DNS server is incorrectly set. Verify that you can browse to the URL in the Android browser.

同样,请确保您具有INTERNET权限.添加

also, make sure you have the INTERNET permission. Add

<uses-permission android:name="android.permission.INTERNET" />

到您的AndroidManifest.xml.

to your AndroidManifest.xml.

这篇关于android发布问题,为什么我收到“主机没有路由"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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