Comments (5)
您好,请使用 HttpUrl 创建,在传入 url 参数时使用 httpUrl.toString():
HttpUrl httpUrl= new HttpUrl.Builder()
.scheme("https")
.host("www.example.com")
.addQueryParameter("key", "value")
.build();
请求时:
HttpRequest.build(context, httpUrl.toString())
.setResponseListener(new ResponseListener() {
@Override
public void onResponse(String response, Exception error) {
...
}
})
.doPost();
from baseokhttpv3.
host 传入ip地址报错
from baseokhttpv3.
请说明是什么错误
from baseokhttpv3.
2020-09-29 12:47:16.125 11246-11246/com.example.transferstation.activity E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.transferstation.activity, PID: 11246
java.lang.IllegalArgumentException: unexpected host: 120.24.62.145:8153/admin/login/token
at okhttp3.HttpUrl$Builder.host(HttpUrl.java:1035)
at com.example.transferstation.activity.LoginActivity.login(LoginActivity.java:89)
at com.example.transferstation.activity.LoginActivity$2.onClick(LoginActivity.java:77)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
from baseokhttpv3.
您好,您的创建方式有误。
请使用如下方式创建:
HttpUrl httpUrl = new HttpUrl.Builder()
.scheme("http")
.host("120.24.62.145")
.port(8153)
.addPathSegment("admin")
.addPathSegment("login")
.addPathSegment("token")
.addQueryParameter("password","123456")
.addQueryParameter("username","test")
.build();
from baseokhttpv3.
Related Issues (20)
- 文件POST上传 HOT 3
- 文件下载建议
- 建议增加 请求错误码统一处理 HOT 1
- 文件上传 大小超过6m提示超时 HOT 18
- kotlin冲突了,怎么排除内部依赖的kotlin-stdlib这个依赖 HOT 2
- 关于文件上传,设置全局请求拦截
- 关于文件下载
- 你好 请问如何返回字节应该怎么处理呢
- 你好,选择了某些文件后点击上传按钮就没反应 HOT 1
- 你好 问下 我mvvm模式 viewmodel里面不适合传入context 请问操作 HOT 3
- 跳过SSL认证
- 文件下载地址若失效,会走onDownloadSuccess回调
- 上传问题 HOT 1
- HttpRequest url为null的逻辑判断有点问题 HOT 1
- 本人小白,不太懂如何解析response,希望大神能教一下。 HOT 2
- websocket HOT 6
- https
- 怎么跳过SSL证书验证,build.skipSSLCheck();这个方法无效
- websocket问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baseokhttpv3.