我在我的网络服务中传递了Emailbody:
String emailBody="<span style='font-size: 14px;font-family:" +
" Arial;'>Following task is now completed.<table width=" +
"'100%' cellpadding='0' cellspacing='0'><tr><td style=" +
"'height: 2px; background-color:'></td></tr>" +
"</table><p>"+remark+"</p> " +
"Completion Date: "+fmdate+"<br /><br /><br /><i>Note: This is automated message. Please do not reply to this email. If you have questions, please contact your Care Team Members.</i></span>";
我的网络服务代码是:
ProgressDialog Dialog;
boolean flag;
String call_method,method1;
HttpClient client;
XmlPullParserFactory factory;
HttpResponse res;
XmlPullParser parser;
@Override
protected Result doInBackground(String...value) {
// TODO Auto-generated method stub
Log.d("submit", "Login");
method1=value[0];
call_method=value[1];
method1=removeSpace(method1);
method1=removePlus(method1);
String method=variable.host+call_method+method1;
Log.d("method","==>"+method);
HttpGet get;
try {
get=new HttpGet(new URI(method));
//get=new HttpGet(new URI(URLEncoder.encode( method , "UTF8" )));
res =LogInActivity.client.execute(get);
factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
Log.i("Bhavik","Response : "+res.getStatusLine().toString());
parser = factory.newPullParser();
parser.setInput(new InputStreamReader(res.getEntity().getContent()));
Log.d("Bhavik", "In Side HTTP "+call_method);
if(call_method.equals("SaveMesage?")){
System.out.println("hello world");
}else{
Messge_Detail_parser pd=new Messge_Detail_parser();
flag=pd.replyData(parser);
}
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
我的例外情况是: -
java.net.URISyntaxException: Illegal character in query at index 231:
请帮我介绍如何在网络服务中传递Html标签。 提前谢谢。
答案 0 :(得分:1)
您可以尝试使用Try HTML.fromhtml()
或URLEncoder.encode(String)
并确保在您当前的字符串中检查位置232处的字符,如果它是一个不需要的不必要的空格,则此错误可能发生。使用您的字符串数据上的trim函数替换不需要的不必要的空格。