转换为Ascii失败了&

时间:2012-05-04 04:04:22

标签: java encoding sms

我们有一个发送短信的java应用程序。我们有2个两个变量集如下所示。然后它经历了一个编码过程。问题现在它工作正常,但在& Time ....之后消息未送达?那么我应该采用什么其他编码机制呢?

String smsMessage = "Asset:TEST1\nSerial ID:Test1\nEvent:Arrive\nDate&Time:2012-04-26 21:06:37\nEvent Location:Location1";
String fullMessageLink="user=tt1&password=tt11&api_id=2211&to=1234567&text="+smsMessage;

URI uri = new URI(
        "http", 
        "api.clickatell.com", 
        "/http/sendmsg",
        fullMessageLink,
        null);

 String request = uri.toASCIIString();

1 个答案:

答案 0 :(得分:3)

&符号&用作URL参数之间的分隔符。请注意&'s中的fullMessageLink。要传递带有&的字符串,您需要URL encode该值。

使用URLEncoder class执行编码。

相关问题