IllegalArgumentException:查询中的非法字符

时间:2013-02-15 08:05:59

标签: android

 protected void onPreExecute()
                {
                    super.onPreExecute();               
                    progressDialog = ProgressDialog.show(getActivity(),"Fetching", "Fetching Contacts", true, false);
                }

                @Override


                protected ArrayList<String> doInBackground(Void... params) {

                // TODO Auto-generated method stub

                ODataConsumer c = ODataJerseyConsumer.create("http://mythreeg.dyndns.org:8088/WcfService_Officetail/WcfDataService.svc/VW_CONTACTS()/?$filter=mobile ne null");

                List<OEntity> listEntities = c.getEntities("VW_CONTACTS").execute().toList();

                System.out.println("Size - " + listEntities.size());



                    for (OEntity entity : listEntities) {

                        categories.add((String) entity.getProperty("contact_name").getValue() + (String) entity.getProperty("mobile").getValue());

                    }

错误:

    02-15 13:26:26.260: E/AndroidRuntime(330): Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 102:
     http://mythreeg.dyndns.org:8088/WcfService_Officetail/WcfDataService.svc/VW_CONTACTS()/?$filter=mobile ne null/$metadata

3 个答案:

答案 0 :(得分:0)

请尝试以下网址

mythreeg.dyndns.org:8088/WcfService_Officetail/WcfDataService.svc/VW_CONTACTS /?$滤波器=移动%20NE%20null

答案 1 :(得分:0)

您可以使用Url.Encoder和URL.Decoder来解决有关URL中使用的特殊字符的非法参数Ecxeption的问题。

答案 2 :(得分:0)

试试这个

url="http://mythreeg.dyndns.org:8088/WcfService_Officetail/WcfDataService.svc/VW_CONTACTS()/?$filter=mobile ne null";
url.replaceAll(" ","%20");
ODataConsumer c = ODataJerseyConsumer.create(url);

只需将%20替换为适用于我的空间