java 使用String.format进行拼接URL连接地址
·
public class TestA {
public static void main(String[] args) {
String P_UserId = "zhangsan";
String P_OrderId = "201611101001";
String P_CardId = "6217230222222222222";
String P_CardPass = "ICBC";
String P_FaceValue = "战士";
String P_ChannelId = "001";
String P_Subject = "转账";
String P_Price = "100.0";
String P_Quantity = "ccc";
String P_Description = "hanson";
String P_Notic = "hanson";
String P_Result_URL = "hanson";
String P_Notify_URL = "hanson";
String P_PostKey = "hanson";
String postUrl = String.format(
"?P_UserId=%s&P_OrderId=%s&P_CardId=%s&P_CardPass=%s&P_FaceValue=%s&P_ChannelId=%s&P_Subject=%s&P_Price=%s"
, P_UserId
, P_OrderId
, P_CardId
, P_CardPass
, P_FaceValue
, P_ChannelId
, P_Subject
, P_Price
);
System.out.println(postUrl);
}
}
public static void main(String[] args) {
String P_UserId = "zhangsan";
String P_OrderId = "201611101001";
String P_CardId = "6217230222222222222";
String P_CardPass = "ICBC";
String P_FaceValue = "战士";
String P_ChannelId = "001";
String P_Subject = "转账";
String P_Price = "100.0";
String P_Quantity = "ccc";
String P_Description = "hanson";
String P_Notic = "hanson";
String P_Result_URL = "hanson";
String P_Notify_URL = "hanson";
String P_PostKey = "hanson";
String postUrl = String.format(
"?P_UserId=%s&P_OrderId=%s&P_CardId=%s&P_CardPass=%s&P_FaceValue=%s&P_ChannelId=%s&P_Subject=%s&P_Price=%s"
, P_UserId
, P_OrderId
, P_CardId
, P_CardPass
, P_FaceValue
, P_ChannelId
, P_Subject
, P_Price
);
System.out.println(postUrl);
}
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)