小编and*_*uke的帖子

通过RestTemplate发送multipart文件

我通过Spring restTemplate使用android发送图像文件(multipart)有一些问题.

这是我服务器上的控制器:

@RequestMapping(value = "/uploadPhoto/{id}", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<String> uploadPhoto(@RequestParam("file") MultipartFile srcFile,
                                               @PathVariable("id") Integer id) {

///  do something

        return RestUtil.getJsonSHttptatus(HttpStatus.NOT_ACCEPTABLE);
    }
Run Code Online (Sandbox Code Playgroud)

这是我的Android活动中的休息请求

private void doUpload(){

        new AsyncTask<String, Void, String>() {

            @Override
            protected String doInBackground(String... params) {

                FormHttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
                formHttpMessageConverter.setCharset(Charset.forName("UTF8"));


                RestTemplate restTemplate = new RestTemplate();


                restTemplate.getMessageConverters().add( formHttpMessageConverter );
                restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());


                restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());

                String uri = "http://localhost:8089/web/uploadPhoto/1";

                String imagePath = "/mnt/sdcard/DCIM/Camera/IMG_20140406_130350.jpg";

                MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
                map.add("expenseId", 1);
                map.add("file", new FileSystemResource(path));

                HttpHeaders imageHeaders …
Run Code Online (Sandbox Code Playgroud)

rest spring android resttemplate spring-android

7
推荐指数
1
解决办法
7528
查看次数

如何在Android中创建弯曲的底部边框矩形?

如何使用xml这样创建具有完美弯曲底部的android drawable:

在此处输入图片说明

我已经尝试过这个xml,但是结果并不完美

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#5f9c63"/>

    <padding android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp" />

    <corners android:bottomRightRadius="100dp"
        android:bottomLeftRadius="100dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

任何的想法 ?

谢谢

android android-xml xml-drawable android-drawable

5
推荐指数
2
解决办法
2532
查看次数