Commit bff6bdd6 by xiaolang850403

公共函数

parent 72f87dc7
package com.asset.common;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException;
......@@ -94,7 +95,7 @@ public class Common {
* @return mixed
*/
public static boolean send_msg(String mobile,String msg) {
public static boolean send_msg(String mobile,String msg) throws UnsupportedEncodingException {
Map<String, Object> map=new HashMap<String, Object>();
map.put("account","tbnn30");
map.put("pswd","JT2k8yx8");
......@@ -115,7 +116,7 @@ public class Common {
* key=value形式的二位数组
* @return
*/
public static String http_build_query(Map<String,Object> array) {
public static String http_build_query(Map<String,Object> array) throws UnsupportedEncodingException {
String reString = null;
//遍历数组形成akey=avalue&bkey=bvalue&ckey=cvalue形式的的字符串
Iterator it = array.entrySet().iterator();
......@@ -127,7 +128,11 @@ public class Common {
}
reString = reString.substring(0, reString.length() - 1);
//将得到的字符串进行处理得到目标格式的字符串
reString = java.net.URLEncoder.encode(reString);
try {
reString = java.net.URLEncoder.encode(reString,"utf-8");
}catch (UnsupportedEncodingException e){
e.printStackTrace();
}
reString = reString.replace("%3D", "=").replace("%26", "&");
return reString;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment