本篇文章为大家展示了如何android在中使用springMvc实现图片上传功能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
具体内容如下
Android端:
String fileName = tvFilename.getText().toString(); RequestBody description = RequestBody.create( okhttp3.MultipartBody.FORM, fileName); File fileImage = new File(saveFileName); RequestBody requestBody1 = RequestBody.create(MediaType.parse("multipart/form-data"), fileImage); MultipartBody.Part body = MultipartBody.Part.createFormData("bannerImage", fileImage.getName(), requestBody1); RestClient.api().addLive(description, body) .enqueue(new retrofit2.Callback() { @Override public void onResponse(retrofit2.Call call, retrofit2.Response response) { "处理成功" } @Override public void onFailure(retrofit2.Call call, Throwable t) { "处理失败" } });