处理url,url为null返回null,url为空串或以http://或https://开头,则加上http://,其他情况返回原参数。

public static String handelUrl(String url) {

if (url == null) {

return null;

}

url = url.trim();

if (url.equals("") || url.startsWith("http://")

|| url.startsWith("https://")) {

return url;

} else {

return "http://" + url.trim();

}

}

猜你喜欢

转载自jccmjl.iteye.com/blog/2258776