1 import java.io.UnsupportedEncodingException;
2 import java.net.URLEncoder;
3 public static String UrlEncode(String result) throws UnsupportedEncodingException{
4 StringBuffer urle = new StringBuffer();
5 String[] results = result.split("&");
6 int i = 0;
7 for(String tempStr : results)
8 {
9 int start = tempStr.indexOf("{");
10 int end = tempStr.lastIndexOf("}")+1;
11 //要urlencode的字符串组合
12 String str = tempStr.substring(start, end);
13 String key = tempStr.replace(str, "");
14 //urlencode的消息体
15 String data = URLEncoder.encode(str, "UTF-8");
16 if(i > 0)
17 {
18 urle.append("&");
19 }
20 urle.append(key);
21 urle.append(data);
22 i++;
23 }
24 return urle.toString();
25 }
26 String req = UrlEncode(Parameters);
27 log.info(req);
28 vars.put("req",req);