0

我可以在 Android 中发布一个 jsf 表单数据吗?例如这个 jsf 页面;

<h:form>
        <h:panelGrid columns="2" border="0">
            <h:outputLabel value="Adınız : "/>
            <h:inputText value="#{pd.ad}"/>
            <h:outputLabel value=""/>
            <h:commandButton value="Gönder" action="#{pd.kontrol()}"/>
        </h:panelGrid>
    </h:form>
<h:outputText value="#{pd.sonuc}" />

我想在 Android 中发布“广告”数据。这是我的 Android 代码;

private TextView postData;
private String url = "http://localhost:8084/AndroidIc_nPOSTsayfa";

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (Build.VERSION.SDK_INT >= 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(url);

    postData = (TextView)findViewById(R.id.postData);

    try {
        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("#{pd.sonuc}", "Mesut Emre"));
        httpPost.setEntity(new UrlEncodedFormEntity(pairs));

        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String response = httpClient.execute(httpPost,responseHandler);
        System.out.println(response);
        postData.setText("Alınan veri:"+response);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

当我运行应用程序时没有错误,但我在 textview 上看不到我发送的数据。

4

0 回答 0