java编译时提示错误:找不到符,如何解决?

****错误: 找不到符号
new StringBody(params.get(index).getValue(),
^
符号: 类 StringBody




```public String submit_Data(String uid, String picpath, String url) {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("image", picpath));
            params.add(new BasicNameValuePair("uid", uid));
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost(url);
            try {
                MultipartEntity entity = new MultipartEntity(
                        HttpMultipartMode.BROWSER_COMPATIBLE);
                for (int index = 0; index < params.size(); index++) {
                    if (params.get(index).getName().equalsIgnoreCase("image")) {
                        System.out.println("post - if");
                        entity.addPart(params.get(index).getName(),
                                new FileBody(new File(params.get(index)
                                        .getValue())));
                    } else {
                        entity.addPart(params.get(index).getName(),
                                  new StringBody(params.get(index).getValue(),
                                        Charset.forName("UTF-8")));
                    }
                }
                httpPost.setEntity(entity);
                HttpResponse response = httpClient.execute(httpPost,
                        localContext);
                responsecode = response.getStatusLine().getStatusCode();
                if (responsecode == 200) {
                    HttpEntity resEntity = response.getEntity();
                    String Response = EntityUtils.toString(resEntity);
                    return Response;
                }
            } catch (Exception e) {
                return "";
            }
            return "";
        }
    }

StringBody 这个类你导入了嘛,检查一下

Charset 这个也需要导入

StringBody 这个类你有导入么?

编辑不出错,运行提示错误!
导入:
import org.apache.http.entity.mime.content.StringBody;
后提示:
错误: 找不到符号
Charset.forName("UTF-8")));
^
符号: 变量 Charset
继续导入:
import java.nio.charset.Charset;
后就一切正常

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^