对于 HttpGet 方法,什么是 getParams()?

编程入门 行业动态 更新时间:2024-10-28 15:31:10
本文介绍了对于 HttpGet 方法,什么是 getParams()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..
org.apache.http.client.methods.HttpGet;

HttpGet method = new HttpGet(url.toExternalForm());
method.getParams()

这些参数是什么?它们是查询字符串吗?似乎没有简单的方法可以使用 org.apache.http.client.methods.HttpGet 来添加查询字符串

Whare are these params? Are they the query string? there seems to be no easy way to add a query string with org.apache.http.client.methods.HttpGet

推荐答案

根据 Http客户端教程,你可以这样做:

According to the Http Client tutorial, you can do this:

URI uri = new URIBuilder()
        .setScheme("http")
        .setHost("www.google")
        .setPath("/search")
        .setParameter("q", "httpclient")
        .setParameter("btnG", "Google Search")
        .setParameter("aq", "f")
        .setParameter("oq", "")
        .build();
HttpGet httpget = new HttpGet(uri);
System.out.println(httpget.getURI());

这篇关于对于 HttpGet 方法,什么是 getParams()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-19 14:46:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/963847.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   HttpGet   getParams

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!